项目作者: eggjs

项目描述 :
eggjs plugin for xtemplate
高级语言: JavaScript
项目地址: git://github.com/eggjs/egg-view-xtpl.git
创建时间: 2017-02-15T09:08:11Z
项目社区:https://github.com/eggjs/egg-view-xtpl

开源协议:MIT License

下载


egg-view-xtpl

NPM version
build status
Test coverage
David deps
Known Vulnerabilities
npm download

egg view plugin for xtemplate.

Install

  1. $ npm i egg-view-xtpl --save

Usage

Configuration

  1. // {app_root}/config/plugin.js
  2. exports.xtpl = {
  3. enable: true,
  4. package: 'egg-view-xtpl',
  5. };
  1. // {app_root}/config/config.default.js
  2. exports.view = {
  3. mapping: {
  4. '.xtpl': 'xtpl',
  5. },
  6. };
  7. // xtpl config
  8. exports.xtpl = {};

see config/config.default.js for more detail.

Example

Demo

  1. // app/view/hello.xtpl
  2. hello {{ data }}

Render it

  1. // app/controller/render.js
  2. exports.xtpl = function* () {
  3. yield this.render('hello.xtpl', {
  4. data: 'world',
  5. });
  6. };

Include

You can include relative file.

  1. // app/view/a.xtpl include app/view/b.xtpl
  2. {{ include('./b.xtpl') }}
  1. // app/view/a.xtpl include app/view/c.xtpl
  2. {{ include('c.xtpl') }}
  1. // app/view/banner/item.xtpl include app/view/footer/logo.xtpl
  2. {{ include('../footer/logo.xtpl') }}

Questions & Suggestions

Please open an issue here.

License

MIT