Commit 3ab7b670 authored by Eric MORAND's avatar Eric MORAND
Browse files

Resolve issue #43

parent 4caa2e90
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16,5 +16,5 @@ Webpack loader for Twig templates, based on [Twing](https://www.npmjs.com/packag

[npm-image]: https://badge.fury.io/js/twing-loader.svg
[npm-url]: https://npmjs.org/package/twing-loader
[coveralls-image]: https://coveralls.io/repos/github/NightlyCommit/twing-loader/badge.svg
[coveralls-url]: https://coveralls.io/github/NightlyCommit/twing-loader
[coveralls-image]: https://coveralls.io/repos/gitlab/nightlycommit/twing-loader/badge.svg
[coveralls-url]: https://coveralls.io/gitlab/nightlycommit/twing-loader
+4 −4
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
    {
      "name": "Eric MORAND",
      "email": "eric.morand@gmail.com",
      "url": "https://github.com/ericmorand"
      "url": "https://gitlab.com/eric.morand"
    },
    {
      "name": "Derek ROTH",
@@ -38,12 +38,12 @@
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/NightlyCommit/twing-loader"
    "url": "https://gitlab.com/nightlycommit/twing-loader"
  },
  "bugs": {
    "url": "https://github.com/NightlyCommit/twing-loader/issues"
    "url": "https://gitlab.com/nightlycommit/twing-loader/-/issues"
  },
  "homepage": "https://github.com/NightlyCommit/twing-loader#readme",
  "homepage": "https://twing-loader.nightlycommit.com",
  "description": "Webpack loader for Twig templates, based on Twing.",
  "devDependencies": {
    "@types/memory-fs": "^0.3.7",
+17 −3
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ Webpack loader for Twig templates, based on [Twing](https://www.npmjs.com/packag

## Usage

twing-loader is a very straightforward Webpack loader, requiring only one option - the `environment` that is used to compile the templates.
`twing-loader` is a very straightforward Webpack loader, requiring only one option, the `environment` that is used to compile the templates.

<sub>webpack.config.mjs</sub>

@@ -53,6 +53,7 @@ module.exports = {
```typescript
import {createEnvironment, createArrayLoader} from "twing";
import template from "./index.twig";
import assert from "assert";

const environment = createEnvironment(createArrayLoader({}));

@@ -63,6 +64,19 @@ template.render(environment, {
});
```

## Template signature

Twig templates imported using this loader are transformed into modules which default export has the following signature:

```typescript
interface Template {
    execute: import("twing").TwingTemplate["execute"];
    render: import("twing").TwingTemplate["render"];
}
```

Please refer to [Twing documentation](https://twing-api.nightlycommit.com/interfaces/TwingTemplate.html) for more information.

## Options

| Name        | Required | Type                               | Description                                                                          |
@@ -71,5 +85,5 @@ template.render(environment, {

[npm-image]: https://badge.fury.io/js/twing-loader.svg
[npm-url]: https://npmjs.org/package/twing-loader
[coveralls-image]: https://coveralls.io/repos/github/NightlyCommit/twing-loader/badge.svg
[coveralls-url]: https://coveralls.io/github/NightlyCommit/twing-loader
[coveralls-image]: https://coveralls.io/repos/gitlab/nightlycommit/twing-loader/badge.svg
[coveralls-url]: https://coveralls.io/gitlab/nightlycommit/twing-loader
+4 −0
Original line number Diff line number Diff line
import assert from "assert";

export {default, type TwingLoaderOptions} from "./lib/loader";

assert(5 === 5);