twig-loader-x
Webpack loader for compiling twig.js templates
Last updated 3 months ago by jusufcodes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install twig-loader-x 
SYNC missed versions from official npm registry.

twig-loader Build Status

Webpack loader for compiling Twig.js templates. This loader will allow you to require Twig.js views to your code.

Installation

npm install twig-loader-x --save-dev

Usage

Documentation: Using loaders


module.exports = {
    //...

    module: {
        rules: [
            {
                test: /\.twig$/,
                loader: 'twig-loader-x',
                options: {
                    // See options section below
                    namespaces: {
                        '@Components': '/your/path/file/'
                    }
                },
            }
        ]
    },

    node: {
        fs: "empty" // avoids error messages
    }
};

Namespaces in Webpack example

{
    test: /\.twig$/,
    loader: 'twig-loader-x',
    options: {
        namespaces: {
            '@Components': '/your/path/file/'
        }
    }
}

Options

  • extender: optional; the full path to a module which exports a function(Twig) which extends Twig (such as adding filters and functions). Example: __dirname + "/src/extendTwig.js"
  • twigOptions: optional; a map of options to be passed through to Twig. Example: {autoescape: true}

Loading templates

{# File: dialog.html.twig #}
<p>{{title}}</p>
// File: app.js
var template = require("dialog.html.twig");
// => returns pre-compiled template as a function and automatically includes Twig.js to your project

var html = template({title: 'dialog title'});
// => Render the view with the given context

When you extend another view, it will also be added as a dependency. All twig functions that refer to additional templates are supported: import, include, extends & embed.

Current Tags

  • 0.5.1                                ...           latest (3 months ago)

2 Versions

  • 0.5.1                                ...           3 months ago
  • 0.5.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |