think-template-twig

1.0.1 • Public • Published

think-template-twig

Twig template adapter for ThinkJS

Install

npm install think-template-twig

How to use

register adapter

import TwigAdapter from 'think-template-twig';
think.adapter('template', 'twig', TwigAdapter);

add above code in bootstrap file, like src/common/bootstrap/adapter.js.

change view type

change view type in file src/common/config/view.js:

export default {
  type: 'twig',
  adapter: {
  twig: { //twig options
  	 //set prerender function if you want extend your twig template
  	 prerender(Twig, templateFile) {
      Twig.extendFunction('repeat', (value, times) => new Array(times+1).join(value));

      //more custom see
      //https://github.com/justjohn/twig.js/wiki/Extending-twig.js
      //https://github.com/justjohn/twig.js/wiki/Extending-twig.js-With-Custom-Tags
      }
    }
  }
}

Readme

Keywords

Package Sidebar

Install

npm i think-template-twig

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • lizheming