This repository has been archived by the owner on Mar 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add option.exportName #98
Open
birhoff
wants to merge
3
commits into
master
Choose a base branch
from
birhoff.feat.#55.add_export_name
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var ${ exportName }; | ||
|
||
(function(global) { | ||
function buildBemXjst() { | ||
var exports = {}; | ||
|
||
${ bemxjst } | ||
|
||
return exports; | ||
}; | ||
|
||
var defineAsGlobal = true; | ||
|
||
// Provide with CommonJS | ||
if (typeof module === 'object' && typeof module.exports === 'object') { | ||
exports['${ exportName }'] = buildBemXjst(); | ||
defineAsGlobal = false; | ||
} | ||
|
||
// Provide to YModules | ||
if (typeof modules === 'object') { | ||
modules.define( | ||
'${ exportName }', | ||
[<%_.each([], function(name) {%>'${ name }',<%});%>], | ||
function( | ||
provide<%if ([].length) {%>,<%}%> | ||
${ [].join(', ') } | ||
) { | ||
provide(buildBemXjst()); | ||
} | ||
); | ||
|
||
defineAsGlobal = false; | ||
} | ||
|
||
// Provide to global scope | ||
if (defineAsGlobal) { | ||
${ exportName } = buildBemXjst(); | ||
global['${ exportName }'] = ${ exportName }; | ||
} | ||
})(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var _ = require('lodash'); | ||
|
||
var assetDir = path.join(__dirname, '..', 'assets'); | ||
var templates = { | ||
bundle: {path: path.join(assetDir, 'bundle.jst')} | ||
}; | ||
|
||
// load templates | ||
_.mapKeys(templates, function (template, name) { | ||
templates[name] = _.template(fs.readFileSync(template.path, 'utf-8')); | ||
}); | ||
|
||
/** | ||
* Template for compile BEMHTML or BEMTREE to bundle. | ||
* | ||
* @param {String} code - Code compiled with the `bem-xjst` (BEMHTML or BEMTREE). | ||
* @param {Object} options - Options. | ||
* @param {String} [options.exportName=BEMHTML] - Name for exports. | ||
* @returns {String} | ||
*/ | ||
module.exports = function (code, options) { | ||
options || (options = {}); | ||
|
||
return templates.bundle({ | ||
exportName: options.exportName || 'BEMHTML', | ||
bemxjst: code | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Могу ошибаться, но @miripiruni это выпиливал (или exportName)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не понял вопроса, судя по доке опции работают
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Опции
engine
больше нет. Есть толькоexportName
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В общем, коммент надо унести к exportName, а это зарезать.
Только не забыть про старые версии