Skip to content

Latest commit

History

47 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

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

Usage

Documentation: Using loaders

module.exports={//...module: {loaders: [{test: /\.twig$/,loader: "twig-loader"}]},node: {fs: "empty"// avoids error messages}};

Loading templates

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

Changelog

0.2.4 / 2016-12-29

0.2.3 / 2016-06-11

  • Improve watch operation (rebuilding of modules)
  • Refactoring so compiler and the loader are in seperate modules
  • Add Twig as peer dependency

0.2.2 / 2016-06-03

  • Add embed support
  • Update Twig.js version

0.2.1 / 2016-04-18

  • Improve import support (zimmo-be#8)
  • Rethrow exceptions when they occur during rendering to improve testing

0.2.0 / 2016-01-21

  • Add support for import statements (useful for Macro's)
  • Correctly resolve dependencies from include/import/extend statements with relative path support: [#3] and [#5]
  • CHANGE: No longer add the .twig file extension. After upgrading twig-loader, you may need to update your files and add .twig manually

About

Webpack loader for compiling Twig.js templates

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages