Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@fiad/vite-plugin-twig

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@fiad/vite-plugin-twig

A simple *[Vite](https://vitejs.dev/guide/api-plugin.html)* plugin for *[Twig](https://twig.symfony.com/doc/3.x/)* template engine usage (based on *[twig.js](https://github.com/twigjs/twig.js/)*).

unpublished
latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

@fiad/vite-plugin-twig

A simple Vite plugin for Twig template engine usage (based on twig.js).

Installation

npm i -D @fiad/vite-plugin-twig

Usage

/* vite.config.js */
import twig from '@fiad/vite-plugin-twig'

export default {
  plugins: [
    twig()
  ]
}

Options

An options object can also be passed as argument with the properties listed here below.

filters

type { [key: string]: (...args: any[]) => any }

default {}

A collection of custom filters to extend Twig. Look at twig.js documentation to learn more.

functions

type { [key: string]: (...args: any[]) => any }

default {}

A collection of custom functions to extend Twig. Look at twig.js documentation to learn more.

globals

type { [key: string]: any }

default {}

The global data to be injected in each template.

settings

type { [key: string]: any }

default {}

The Twig settings. Please refer to twig.js documentation to learn more.

Templates

The html files located by default in the Vite project root are not intented to be replaced directly by the twig ones as the normal page files resolution/linking on the Vite's dev server is wanted to be preserved along with the build logic. However, those files are supposed to contain a json definition instead of the traditional markup, which should be moved on the twig side.

More in details, a html file should look like this:

<!-- index.html -->
<script type="application/json">
  {
    "template": "path/to/template.twig",
    "data": {
      "title": "Homepage"
    }
  }
</script>

where template is the path of the twig template to be rendered (relative to the cwd), and data is the local context for that page (eventually merged with the globals provided via plugin options).

Keywords

vite-plugin

FAQs

Package last updated on 03 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts