Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

jbockle/aurelia-node-templating-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aurelia-node-templating-engine

npm

Compile Aurelia templates from node!

Why?

I needed to build a templating engine for an emailer service, and why not continue using Aurelia for it??

Installation

npm install aurelia-node-templating-engine

Use

import 'aurelia-polyfills';
import { AureliaNodeTemplatingEngine } from '../src/aurelia-node-templating-engine';

const view = `
    <span>\${message}</span>
    <ul>
        <li repeat.for="item of items">\${item}</li>
    </ul>
`;

const contexts = [
    {
        message: 'hello world!',
        items: [
            'jim',
            'bob',
        ],
    }, {
        message: 'hello again world!',
        items: [
            'sue',
            'jim',
        ],
    }, {
        message: 'goodbye world!',
        items: [
            'bob',
            'jim',
        ],
    },
];

(async () => {

    const engine = new AureliaNodeTemplatingEngine(view);

    const timer = 'compile view/view-model';
    for (const context of contexts) {
        console.time(timer);

        const result = await engine.compile(context);

        console.log(result);

        console.timeEnd(timer);
    }
})();

outputs

<div>
    <span>hello world!</span>
    <ul>
        <li>jim</li><li>bob</li><!--anchor-->
    </ul>
</div>
first template compile is longest
compile view/view-model: 75.626ms 
<div>
    <span>hello again world!</span>
    <ul>
        <li>sue</li><li>jim</li><!--anchor-->
    </ul>
</div>
compile view/view-model: 4.532ms
<div>
    <span>goodbye world!</span>
    <ul>
        <li>bob</li><li>jim</li><!--anchor-->
    </ul>
</div>
compile view/view-model: 2.923ms

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published