GithubHelp home page GithubHelp logo

isabella232 / twig-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from widgetworks/twig-loader

0.0 0.0 0.0 45 KB

Webpack loader for compiling Twig.js templates

License: MIT License

JavaScript 100.00%

twig-loader's Introduction

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: {
        rules: [
            {
                test: /\.twig$/,
                loader: "twig-loader",
                options: {
                    // See options section below
                },
            }
        ]
    },

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

Options

  • 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.

Changelog

0.4.1 / 2018-06-12

  • Upgrade mocha to fix security vulnerability warning

0.4.0 / 2018-05-17

  • Add ablity to pass options to twig (PR #39)

0.3.1 / 2017-11-08

  • Update to Twig.js 1.10, fixes #29

0.3.0 / 2017-02-19

  • replace full path with a hash and implement mapcache for id/path resolution, fixes #12

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

twig-loader's People

Contributors

mathieuzimmo avatar webberig avatar dragorww avatar tremby avatar benjamminf avatar pmaeria avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.