1.1.1 • Published 4 years ago

smarty-server v1.1.1

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

node-smarty-server

Render smarty template in local for quick development.

Language Build Status npm package npm downloads semantic-release

install

npm i [-g] smarty-server

usage

  1. config file

    make a config file like this:

    const fs = require('fs');
    const path = require('path');
    
    module.exports = {
        routes: {
            '/': {
                templatePath: '/path/to/index.tpl'
            },
            '/page': {
                templatePath: '/path/to/another/page.tpl'
            }
        },
    
        // smarty will find template based on this path
        templateRootPath: path.resolve(__dirname, '../output/template'),
    
        // will start a static file server on this path
        staticRootPath: path.resolve(__dirname, '../output'),
    
        smartyConfig: {
            delimiters: {
                left: '{%',
                right: '%}'
            }
        },
    
        // will load smarty plugins in these paths, can be a string or string[]
        pluginPaths: path.resolve(__dirname, '../tool/plugins'),
    
        // will use this function's return as data to render template
        mockData(url) {
            return fs.readFileSync(path.resolve(__dirname, './mock.json'), {encoding: 'utf8'});
        }
    };
  2. run

    smarty-server start -c path/to/config.js 
1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago