1.5.4 • Published 9 years ago

cortex-handlebars-compiler v1.5.4

Weekly downloads
7
License
MIT
Repository
github
Last release
9 years ago

cortex-handlebars-compiler NPM version Build Status Dependency Status

Handlebar helpers for cortex template.

Install

$ npm install cortex-handlebars-compiler --save

Usage

var compiler = require('cortex-handlebars-compiler');

compiler(options)

Returns the compiler.Compiler instance.

Class: compiler.Compiler(options)

A single compiler instance only cares about one template file.

  • options Object
    • pkg Object object of cortex.json
    • shrinkWrap Object object of cortex-shrinkwrap.json
    • cwd path the root directories of current project.
    • path path path of the current template file
    • href_root url the url base of the hyper reference, 'efte://efte' for example.

.compile(template)

  • template String template string

Parses the template string and returns function(data) the parsed function.

template:

<body>
{{{facade 'a@1.0.0'}}}
</body>
instance.compile(template)();

Then you will get: (which is beautified)

<html>
<head></head>
<body>

<script src="../../../neuron/5.1.0/neuron.min.js"></script>
<script>
neuron.config({
  ranges: tree
  path: "../../../"
});
</script>
<script>
facade({
  mod:"cortex-hybrid-sample@0.1.0"
});
</script>
</body>
</html>

.register(helper, handler)

  • helper String the name of the helper
  • handler function(title, helper_options) see handlebars for details

Registers a new helper handler.

Returns this.

Built-in helpers

{{{facade '<package-name>'}}}

The first 'facade' will also output the engines and configurations.

{{{href '<link>'}}}

Creates a special link to navigate through business units

link

Relative links: ./page.html

External link to other units: <unit-name>/path/to.html

<!-- 
  If the current unit is 'foo', 
  and the current template is 'template/a.html'
-->
<a href="{{{href './b.html'}}}" >link</a>
<a href="{{{href 'bar/folder/index.html'}}}">external link</a>

You will get:

<a href="efte://efte/foo/template/a.html">link</a>
<a href="efte://efte/bar/folder/index.html">external link</a>

License

MIT

1.5.4

9 years ago

1.5.3

9 years ago

1.5.2

9 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.6

9 years ago

1.4.5

9 years ago

1.4.4

9 years ago

1.4.3

9 years ago

1.4.2

9 years ago

1.4.0

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago