├── .jshintrc
├── Changelog.md
├── LICENSE
├── README.md
├── defaultPlugins
└── compositionViews.js
├── genDoc.js
├── index.js
├── jsdoc
├── README.md
├── all.min.js
├── all.min.js.map
├── data.json
├── index-dev.html
├── index.html
├── lib
│ ├── backbone
│ │ └── backbone.js
│ ├── bootstrap-3.2.0-dist
│ │ ├── css
│ │ │ ├── bootstrap-theme.css
│ │ │ ├── bootstrap-theme.css.map
│ │ │ ├── bootstrap-theme.min.css
│ │ │ ├── bootstrap.css
│ │ │ ├── bootstrap.css.map
│ │ │ └── bootstrap.min.css
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.svg
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ └── glyphicons-halflings-regular.woff
│ │ └── js
│ │ │ ├── bootstrap.js
│ │ │ └── bootstrap.min.js
│ ├── jquery
│ │ └── jquery-2.0.3.min.js
│ ├── marked
│ │ └── marked.js
│ ├── prettify
│ │ ├── prettify.css
│ │ └── prettify.js
│ ├── toast
│ │ └── toast.min.js
│ ├── twitter-typeahead
│ │ └── typeahead.bundle.js
│ └── vis
│ │ └── dist
│ │ ├── img
│ │ ├── network
│ │ │ ├── acceptDeleteIcon.png
│ │ │ ├── addNodeIcon.png
│ │ │ ├── backIcon.png
│ │ │ ├── connectIcon.png
│ │ │ ├── cross.png
│ │ │ ├── cross2.png
│ │ │ ├── deleteIcon.png
│ │ │ ├── downArrow.png
│ │ │ ├── editIcon.png
│ │ │ ├── leftArrow.png
│ │ │ ├── minus.png
│ │ │ ├── plus.png
│ │ │ ├── rightArrow.png
│ │ │ ├── upArrow.png
│ │ │ └── zoomExtends.png
│ │ └── timeline
│ │ │ └── delete.png
│ │ ├── vis.css
│ │ ├── vis.js
│ │ ├── vis.map
│ │ ├── vis.min.css
│ │ └── vis.min.js
├── libs.min.js
├── libs.min.js.map
├── src
│ ├── JsDocMaker_browser.js
│ ├── js
│ │ ├── AbstractTreeView.js
│ │ ├── AbstractView.js
│ │ ├── Application.js
│ │ ├── ApplicationView.js
│ │ ├── ClassView.js
│ │ ├── DependenciesView.js
│ │ ├── FileView.js
│ │ ├── HeaderView.js
│ │ ├── HierarchyTreeView.js
│ │ ├── IndexView.js
│ │ ├── JsDocRouter.js
│ │ ├── MethodView.js
│ │ ├── ModuleView.js
│ │ ├── ParseView.js
│ │ ├── PropertyView.js
│ │ ├── SearchView.js
│ │ ├── SourcesView.js
│ │ ├── TreeView.js
│ │ └── TypesUtil.js
│ ├── styles
│ │ ├── class.less
│ │ ├── header.less
│ │ ├── index.less
│ │ ├── main-layout.less
│ │ ├── main.less
│ │ ├── module.less
│ │ ├── parse.less
│ │ ├── sources.less
│ │ ├── styles.css
│ │ ├── tree.less
│ │ └── types.less
│ └── templates
│ │ ├── application.html
│ │ ├── class.html
│ │ ├── classSummary.html
│ │ ├── classes.html
│ │ ├── dependencies.html
│ │ ├── file.html
│ │ ├── header.html
│ │ ├── hierarchytree.html
│ │ ├── index.html
│ │ ├── method.html
│ │ ├── module.html
│ │ ├── modules.html
│ │ ├── parse.html
│ │ ├── project-metadata.html
│ │ ├── property.html
│ │ ├── search.html
│ │ ├── sources.html
│ │ ├── tree.html
│ │ └── typeaheadSuggestion.html
└── template-output.js
├── lib
├── Adapters
│ ├── incrementalDOMAdapter.js
│ ├── reactAdapter.js
│ └── virtualDOMAdapter.js
├── codeGenerator.Attributes.js
├── codeGenerator.Base.js
├── codeGenerator.CustomHelpers.js
├── codeGenerator.Tags.js
├── codeGenerator.Utils.js
├── codeGenerator.js
└── hookContainer.js
├── package.json
├── spec
├── combinationHandlebarsHTMLSpec.js
├── simpleHTMLAttributesSpec.js
├── simpleHTMLTagsSpec.js
├── simpleHandlebarsAttributesSpec.js
├── simpleHandlebarsTagsSpec.js
└── support
│ └── jasmine.json
└── status.txt
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | // JSHint Default Configuration File (as on JSHint website)
3 | // See http://jshint.com/docs/ for more details
4 |
5 | "maxerr" : 100, // {int} Maximum error before stopping
6 |
7 | // Enforcing
8 | "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
9 | "camelcase" : false, // true: Identifiers must be in camelCase
10 | "curly" : true, // true: Require {} for every new block or scope
11 | "eqeqeq" : true, // true: Require triple equals (===) for comparison
12 | "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
13 | "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
14 | "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
15 | "indent" : 4, // {int} Number of spaces to use for indentation
16 | "latedef" : false, // true: Require variables/functions to be defined before being used
17 | "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
18 | "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
19 | "noempty" : true, // true: Prohibit use of empty blocks
20 | "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
21 | "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
22 | "plusplus" : false, // true: Prohibit use of `++` & `--`
23 | "quotmark" : "single", // Quotation mark consistency:
24 | // false : do nothing (default)
25 | // true : ensure whatever is used is consistent
26 | // "single" : require single quotes
27 | // "double" : require double quotes
28 | "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
29 | "unused" : true, // Unused variables:
30 | // true : all variables, last function parameter
31 | // "vars" : all variables only
32 | // "strict" : all variables, all function parameters
33 | "strict" : true, // true: Requires all functions run in ES5 Strict Mode
34 | "maxparams" : false, // {int} Max number of formal params allowed per function
35 | "maxdepth" : false, // {int} Max depth of nested blocks (within functions)
36 | "maxstatements" : false, // {int} Max number statements per function
37 | "maxcomplexity" : false, // {int} Max cyclomatic complexity per function
38 | "maxlen" : false, // {int} Max number of characters per line
39 |
40 | // Relaxing
41 | "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
42 | "boss" : false, // true: Tolerate assignments where comparisons would be expected
43 | "debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
44 | "eqnull" : false, // true: Tolerate use of `== null`
45 | "es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
46 | "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
47 | "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
48 | // (ex: `for each`, multiple try/catch, function expression…)
49 | "evil" : false, // true: Tolerate use of `eval` and `new Function()`
50 | "expr" : false, // true: Tolerate `ExpressionStatement` as Programs
51 | "funcscope" : false, // true: Tolerate defining variables inside control statements
52 | "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
53 | "iterator" : false, // true: Tolerate using the `__iterator__` property
54 | "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
55 | "laxbreak" : false, // true: Tolerate possibly unsafe line breakings
56 | "laxcomma" : true, // true: Tolerate comma-first style coding
57 | "loopfunc" : false, // true: Tolerate functions being defined in loops
58 | "multistr" : false, // true: Tolerate multi-line strings
59 | "noyield" : false, // true: Tolerate generator functions with no yield statement in them.
60 | "notypeof" : false, // true: Tolerate invalid typeof operator values
61 | "proto" : false, // true: Tolerate using the `__proto__` property
62 | "scripturl" : false, // true: Tolerate script-targeted URLs
63 | "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
64 | "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
65 | "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
66 | "validthis" : false, // true: Tolerate using this in a non-constructor function
67 |
68 | // Environments
69 | "browser" : false, // Web Browser (window, document, etc)
70 | "browserify" : false, // Browserify (node.js code in the browser)
71 | "couch" : false, // CouchDB
72 | "devel" : true, // Development/debugging (alert, confirm, etc)
73 | "dojo" : false, // Dojo Toolkit
74 | "jasmine" : false, // Jasmine
75 | "jquery" : false, // jQuery
76 | "mocha" : true, // Mocha
77 | "mootools" : false, // MooTools
78 | "node" : true, // Node.js
79 | "nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
80 | "phantom" : false, // PhantomJS
81 | "prototypejs" : false, // Prototype and Scriptaculous
82 | "qunit" : false, // QUnit
83 | "rhino" : false, // Rhino
84 | "shelljs" : false, // ShellJS
85 | "typed" : false, // Globals for typed array constructions
86 | "worker" : false, // Web Workers
87 | "wsh" : false, // Windows Scripting Host
88 | "yui" : false, // Yahoo User Interface
89 |
90 | // Custom Globals
91 | "globals" : {} // additional predefined global variables
92 | }
--------------------------------------------------------------------------------
/Changelog.md:
--------------------------------------------------------------------------------
1 | #Changelog
2 |
3 | ##Version 0.1.0 (14-09-2015)
4 | * Added Adapters
5 | * Added basic React adapter
6 | * Generated first iteration of auto-generated-documentation
7 |
8 | ##Version 0.0.3 (23-08-2015)
9 | * Publically exposed plugins
10 | * Added some Unit Tests
11 |
12 | ##Version 0.0.2 (22-08-2015)
13 | * Fixed README documentation
14 | * Fixed code documentation
15 |
16 | ##Version 0.0.1 (21-08-2015)
17 | * Initial Version
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Mictian
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # blueHTML
2 | Simple [handlebar] to [virtual-dom] converter
3 | [handlebar]:http://handlebarsjs.com/
4 | [virtual-dom]:https://github.com/Matt-Esch/virtual-dom
5 |
6 | ## Overview
7 |
8 | Simple converter from HTML/Handlebars templates into virtual-dom.
9 |
10 | PR Accepted (Specially Unit Tests :D )
11 |
12 | ## API & Samples
13 |
14 | ```javascript
15 | var blueHTML = require('bluehtml')
16 | , h = require('virtual-dom/h')
17 | , _ = require("underscore")
18 |
19 |
20 | var template_string = '
{{title}}
{{mainContent}}
'
21 | , virtual_dom = blueHTML.generateVirtualDOM(template_string, {notGenerateContext:true})
22 | , context = {
23 | title: 'Test Title',
24 | mainContent: 'Hello word'
25 | };
26 |
27 | console.log(virtual_dom);
28 |
29 | var eval_fn = "var ctx = " + JSON.stringify(context) + ';' + virtual_dom;
30 |
31 | var virtual_dom_output = eval(eval_fn);
32 | console.log(virtual_dom_output);
33 |
34 | ```
35 |
36 | ## Motivation
37 | I personally believe in the one-way data-flow pattern is an excellent way to model user interaction
38 | and I think that from an architectural point of view it has a lot of advantages.
39 |
40 | Besides, all the great development that have been done with Virtual DOM
41 | technologies is something that cannot be ignored. Perhaps you can like it not,
42 | but for a performance point of view I think that React have leave it crystal clear.
43 |
44 | Although all the previous, I do not want to re-write all my Handlebars templates
45 | to JavaScript (JSX, HyperScript or whatever flavor you want) nor I think that designers should start
46 | writing JavaScript instead of HTML templates.
47 | All this VirtualDOM technologies are great, but this does not mean that we must change the way
48 | we have been working on, by the contrary, we can enhance the way we used to work.
49 | Take for instance a Backbone.js application with Handlebars (the way I work), in this case Handlebars is not used
50 | as a final representation of the HTML, but rather as a friendly way the designer can work with it.
51 | You will process your Handlebars template obtaining an output, point at which you
52 | will neither use this output as a final representation, and wrap it with jQuery or any other equivalent.
53 |
54 | So, my point is that we can use any other intermediate representation for our templates,
55 | jQuery, VirtualDOM or the one you think is better, as long as we keep a clear separation
56 | between what the aim of each part is.
57 |
58 | ## Documentation
59 | For a general overview please refer to the [Wiki](https://github.com/Mictian/blueHTML/wiki/General-Documentation) and more technical one please refer to the code which is fully documented.
60 |
61 |
62 | ## Changelog
63 | Go [Here](https://github.com/Mictian/blueHTML/blob/master/Changelog.md) to see the list of changes.
64 |
65 | # Contributors
66 | * juansilva (https://github.com/juansilva)
67 |
68 | # License
69 | The MIT License (MIT)
70 |
71 | Copyright (c) 2015 Mictian
72 |
73 | Permission is hereby granted, free of charge, to any person obtaining a copy
74 | of this software and associated documentation files (the "Software"), to deal
75 | in the Software without restriction, including without limitation the rights
76 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77 | copies of the Software, and to permit persons to whom the Software is
78 | furnished to do so, subject to the following conditions:
79 |
80 | The above copyright notice and this permission notice shall be included in all
81 | copies or substantial portions of the Software.
82 |
83 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
84 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
85 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
86 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
87 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
89 | SOFTWARE.
90 |
--------------------------------------------------------------------------------
/defaultPlugins/compositionViews.js:
--------------------------------------------------------------------------------
1 | //@module blueHTML.DefaultPlugins
2 | var _ = require('underscore');
3 |
4 | //@class CompositeViewPlugin @extend Plugin This plugin allows to composite views by adding a data-view attribute inside the Handlebars template
5 | module.exports = {
6 | //@method install Public method invoked by blueHTML when adding a new plugin.
7 | //@param {CodeGenerator} codeGenerator
8 | //@return {Void}
9 | install: function (codeGenerator)
10 | {
11 | 'use strict';
12 |
13 | this.accumulatedAttributesCompositeViewNames = [];
14 | this.compositeViewNames = [];
15 | this.lastAttributesResult = '';
16 | this.externalDependencyVariableName = 'children_views_dependencies';
17 |
18 | codeGenerator.beforeAttributeHandlerExecuted.add({
19 | name: 'Recollect data-view values'
20 | , execute: this.beforeAttributeHandlerCalled
21 | , priority: 10
22 | , self: this
23 | });
24 |
25 | codeGenerator.afterAttributeCodeGeneration.add({
26 | execute: this.augmentNodeChildrenForCompositeViews
27 | , name: 'Insert AST dataView nodes'
28 | , priority: 10
29 | , self: this
30 | });
31 |
32 | codeGenerator.beforeAttributeCodeGeneration.add({
33 | execute: this.cleanAttributeCompositeViews
34 | , name: 'Reset local state'
35 | , priority: 10
36 | , self: this
37 | });
38 |
39 | codeGenerator.afterTagCodeGeneration.add({
40 | execute: this.generateResult
41 | , name: 'Extend Generated code result'
42 | , priority: 10
43 | , self: this
44 | });
45 |
46 | this.extensionMethods.pluginCompositeViewsContext = this;
47 |
48 | _.extend(codeGenerator.prototype, this.extensionMethods);
49 | },
50 |
51 | //@method cleanAttributeCompositeViews
52 | //@return {Void}
53 | cleanAttributeCompositeViews: function ()
54 | {
55 | 'use strict';
56 |
57 | this.self.accumulatedAttributesCompositeViewNames = [];
58 | this.self.lastAttributesResult = '';
59 | },
60 |
61 | //@method generateResult Extend the final result to return the list of view named collected
62 | //@param {CodeGenerationResult} codeResult
63 | //@return {CodeGenerationResult}
64 | generateResult: function (codeResult)
65 | {
66 | codeResult.externalDependencies = codeResult.externalDependencies.concat(this.self.compositeViewNames);
67 | return codeResult;
68 | },
69 |
70 | //@method beforeAttributeHandlerCalled Hook to accumulate data-view attributes
71 | //@param {AttributeASTNode} ast_node
72 | //@param {CodeGenerationContext} code_generation_context
73 | //@return {Void}
74 | beforeAttributeHandlerCalled: function (ast_node, code_generation_context)
75 | {
76 | 'use strict';
77 |
78 | var self = this.self;
79 |
80 | if (ast_node.type === 'keyValue' && 'data-view' === ast_node.key)
81 | {
82 | var composite_view_name = '""';
83 |
84 | //Generate view name (It can be compose by code invocation)
85 | _.each(ast_node.value, function (value_node)
86 | {
87 | if (value_node.type === 'singleValue' ||
88 | (value_node.type === 'singleKey' && value_node.subType === 'extraSpaces' && value_node.value !== ''))
89 | {
90 | composite_view_name += '+"'+value_node.value+'"';
91 | }
92 | else if (value_node.type === 'handlebars' && value_node.subType === 'ATTRREFERENCEEVALUATION')
93 | {
94 | var property_name = value_node.value.trim().substr(1);
95 | if (code_generation_context.currentContextName[property_name])
96 | {
97 | composite_view_name += '+'+code_generation_context.currentContextName.contextName + '.' + property_name;
98 | }
99 | }
100 | });
101 |
102 | self.accumulatedAttributesCompositeViewNames.push(composite_view_name);
103 | }
104 | },
105 |
106 | //@method augmentNodeChildrenForCompositeViews Internal method to add for each NodeASTNode that has properties the can indicate that the node is a composite point
107 | // an extra child to express that composite point
108 | //@param {String} attributes_result
109 | //@param {CodeGenerationContext} code_generation_context
110 | //@return {Void}
111 | augmentNodeChildrenForCompositeViews: function (attributes_result, code_generation_context)
112 | {
113 | 'use strict';
114 |
115 | var self = this.self
116 | , node_children = code_generation_context.astNode.children || [];
117 |
118 | _.each(self.accumulatedAttributesCompositeViewNames, function (require_composite_view)
119 | {
120 | node_children.push({
121 | type: 'handlebars'
122 | , subType: 'CompositeView'
123 | , value: require_composite_view
124 | , parameters: attributes_result.value
125 | });
126 | });
127 | self.compositeViewNames = self.compositeViewNames.concat(self.accumulatedAttributesCompositeViewNames);
128 |
129 | code_generation_context.astNode.children = node_children;
130 | self.lastAttributesResult = attributes_result;
131 | },
132 |
133 | extensionMethods: {
134 |
135 | //@method handlebarsCompositeView Handler for (extra added) composite nodes
136 | //@param {CodeGenerationContext} code_generation_context
137 | //@return {String}
138 | handlebarsCompositeView: function (code_generation_context)
139 | {
140 | 'use strict';
141 |
142 | var self = this.pluginCompositeViewsContext;
143 |
144 | var invokable_fn = code_generation_context.externalDependenciesObjectName+'['+code_generation_context.astNode.value+']'
145 | , output_code = ''
146 | , generate_virtualdom = !!(code_generation_context.adapter && code_generation_context.adapter.name === 'VD')
147 | , generate_react = !!(code_generation_context.adapter && code_generation_context.adapter.name === 'R');
148 |
149 | if (generate_virtualdom)
150 | {
151 | output_code = '(function (){ '+
152 | 'if (_.isFunction('+invokable_fn+')) { return '+invokable_fn+'('+self.lastAttributesResult+'); }' +
153 | 'return []; })()';
154 | }
155 | else if (generate_react)
156 | {
157 | output_code = '(function (){ '+
158 | 'if (_.isFunction('+invokable_fn+')) { return React.createElement('+invokable_fn+'('+self.lastAttributesResult+'),null); }' +
159 | 'return []; })()';
160 | }
161 | else
162 | {
163 | throw new Error('Composite Views Plugin is being used with an adapter that is not supported. Only VirtualDOM and React are supported by this plugin');
164 | }
165 |
166 | if (code_generation_context.isInsideContext)
167 | {
168 | return code_generation_context.variableName + '=' + code_generation_context.variableName + '.concat('+output_code+');';
169 | }
170 |
171 | return output_code;
172 | }
173 | }
174 | };
175 |
--------------------------------------------------------------------------------
/genDoc.js:
--------------------------------------------------------------------------------
1 | var ShortJsDoc = require('short-jsdoc')
2 | , rimraf = require('rimraf');
3 |
4 | rimraf('./jsdoc/', function ()
5 | {
6 | ShortJsDoc.make({
7 | inputDirs: ['./lib', './index.js']
8 | , output: 'jsdoc'
9 | , projectMetadata: './package.json'
10 | , vendor: []
11 | });
12 | })
13 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | //@module blueHTML
2 | var codeGenerator = require('./lib/codeGenerator')
3 | , _ = require('underscore')
4 | , virtualDOMAdapter = require('./lib/Adapters/virtualDOMAdapter')
5 | , reactAdapter = require('./lib/Adapters/reactAdapter')
6 | , compositeViewPlugin = require('./defaultPlugins/compositionViews');
7 |
8 | var local_parser = new codeGenerator()
9 | , defaultsAdapters = {
10 | 'VD': virtualDOMAdapter
11 | , 'R': reactAdapter
12 | };
13 |
14 | //@class blueHTML
15 | module.exports = {
16 | //@property {CodeGenerator} codeGenerator
17 | codeGenerator: codeGenerator
18 |
19 | //@method generateVirtualDOM Shortcut method to easily start converting handlebarsX to virtual-dom
20 | //@param {String} string_html Handlebar HTML template
21 | //@param {VirtualDOMGenerationOptions} options List of option to configure the parsing process
22 | //@return {String} Final virtual-dom string code already wrapped in a functions
23 | , generateVirtualDOM: function (string_html, options)
24 | {
25 | 'use strict';
26 |
27 | options = _.defaults(options || {}, {
28 | notGenerateContext: false
29 | , adapterName: 'VD'
30 | });
31 |
32 | options.adapter = options.adapter || defaultsAdapters[options.adapterName];
33 |
34 | var result = local_parser.generateCode(string_html, options);
35 |
36 | return result.value;
37 | }
38 | //@property {Object} defaultPlugins Each property of this object is of type Plugin
39 | , defaultPlugins: {
40 | 'compositeViews': compositeViewPlugin
41 | }
42 | //@property {Object} defaultsAdapters Each property of this object is of type Adapter
43 | , defaultsAdapters: defaultsAdapters
44 | //@method addCustomHandler Method used to define a new custom Handlebars Helper
45 | //@param {ExtenderCodeGeneratorObject} handlebars_custom_handlers
46 | //@return {Void}
47 | , addCustomHandler: local_parser.addCustomHandler
48 | //@method installPlugin Install a plugin inside the code generator
49 | //@param {Plugin} plugin_container
50 | //@return {Void}
51 | , installPlugin: local_parser.installPlugin
52 | };
53 |
54 |
55 | // @class ExtenderCodeGeneratorObject Object used to extend any of the code generators.
56 | // In this object each property must be a function. Two kind of functions are supported:
57 | // * **Extension Functions**: These are functions that will take the parameters from the Code generator and output a string code.
58 | // This can be seen as a point to extend the code generator it self.
59 | // This functions are distinguish by the property name they are attached to. In this case the name MUST start with the word 'single' and MUST NOT be 'singleInstance'
60 | // Sample:
61 | // ```javascript
62 | // var blueHTML = require('blueHTML');
63 | // blueHTML.addCustomHandler({
64 | // 'singleTranslate': function (parsing_context, is_inside_context)
65 | // {
66 | // return 'h("div",[])';
67 | // }
68 | // });
69 | // ```
70 | // In this sample, that function will be called each time that in the HTML code appears something like:
71 |
72 | // ```html
73 | // {{Translate 'some options'}}
74 | // ```
75 |
76 | // Each function MUST fulfill the following signature:
77 | // **Function** where the output is string and the rest are the input parameter types.
78 |
79 | // For the previous codes, the output will be:
80 | // ```javascript
81 | // function render(ctx)
82 | // {
83 | // return h('span', {}, [h('div',[])]);
84 | // }
85 | // ```
86 |
87 | // * **Helper Functions:** The second options are functions defined in almost the same way you define custom helpers in Handlebars. These functions are distinguish by the property name they are atteched to. In this case the name MUST start with the word 'singleInstance'
88 |
89 | // Sample:
90 | // ```javascript
91 | // var blueHTML = require('blueHTML');
92 | // blueHTML.addCustomHandler({
93 | // 'singleInstanceTranslate': function (string_key_to_translate)
94 | // {
95 | // return 'key not found :(';
96 | // }
97 | // });
98 | // ```
99 | // In this sample, that function will be called each time that in the HTML code appears something like:
100 |
101 | // ```html
102 | // {{Translate 'some options'}}
103 | // ```
104 |
105 | // The big difference with previous functions is the signature. While extension function must have a rigid signature that will be called by the code generator, helper functions can have any signature. In the same way you did with Handlebars.
106 |
107 | // **Important Note:**
108 | // 1. As you can guess, this functions are prefixed with the word *single* as their aim is to handle single helpers. In order word, by the time being **generic block are not supported!!**
109 | // 2. The examples here applies to both Attributes and Tags
110 |
111 |
--------------------------------------------------------------------------------
/jsdoc/README.md:
--------------------------------------------------------------------------------
1 | This is an html5 application generated by short-jsdoc that shows some project's jsdocs.
2 |
3 | The application is based on bootstrap, backbone, underscore templates, less.
--------------------------------------------------------------------------------
/jsdoc/index-dev.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
70 |
71 |
72 |
73 |
74 |
75 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/jsdoc/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/jsdoc/lib/bootstrap-3.2.0-dist/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mictian/blueHTML/0036ff5b3e62662348e72a56831c327d4b77e38b/jsdoc/lib/bootstrap-3.2.0-dist/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/jsdoc/lib/bootstrap-3.2.0-dist/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mictian/blueHTML/0036ff5b3e62662348e72a56831c327d4b77e38b/jsdoc/lib/bootstrap-3.2.0-dist/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/jsdoc/lib/bootstrap-3.2.0-dist/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mictian/blueHTML/0036ff5b3e62662348e72a56831c327d4b77e38b/jsdoc/lib/bootstrap-3.2.0-dist/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/jsdoc/lib/prettify/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
--------------------------------------------------------------------------------
/jsdoc/lib/prettify/prettify.js:
--------------------------------------------------------------------------------
1 | !function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
2 | (function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a=
3 | b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;ah[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10 | q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com",
11 | /^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+
12 | s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,
13 | q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d=
14 | c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],
19 | O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20 | Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,
21 | V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^]+/],["dec",/^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",
22 | /^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^