template(filename, content)
Render templates according to template name.
- Parameters:
{string} filename
{Object,string} content
- Return:
- if
content
isObject
,render template and returnstring
- if
content
isstring
,compile template and returnfunction
- if
var html = template('/welcome.art', { |
browser version can not load external file.
filename
is the elementid
of template
Examples
Compile templates and cache it.
// compile && cache |
.compile(source, options)
Compile templates and return a rendering function.
- Parameters:
{string} source
{Object} options
- Return:
{function}
Examples
var render = template.compile('hi, <%=value%>.'); |
.render(source, data, options)
Compile and return rendering results.
- Parameters:
{string} source
{Object} options
- Return:
{string}
Examples
var html = template.render('hi, <%=value%>.', {value: 'aui'}); |
.defaults
Default configuration of template engine. Refer to Options.
- Type:
{Object}
.extension
Template rendering function registering for NodeJS require.extensions
.
- Type:
{Object}
Examples
Load .ejs
templates:
var template = require('art-template'); |
.art
is registered by default and you can use it directly:
var template = require('art-template'); |
It should be noted that this functionality only works for NodeJS. If you want to use template rendering functionality, please use Webpack art-template-loader.