# rollup-plugin-posthtml-template **Repository Path**: mirrors_posthtml/rollup-plugin-posthtml-template ## Basic Information - **Project Name**: rollup-plugin-posthtml-template - **Description**: Seamless integration between Rollup and PostHTML, and rendering template properties. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2025-09-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # rollup-plugin-posthtml-template [![Build Status](https://travis-ci.org/Vanilla-IceCream/rollup-plugin-posthtml-template.svg?branch=master)](https://travis-ci.org/Vanilla-IceCream/rollup-plugin-posthtml-template) [![Coverage Status](https://coveralls.io/repos/github/Vanilla-IceCream/rollup-plugin-posthtml-template/badge.svg?branch=master)](https://coveralls.io/github/Vanilla-IceCream/rollup-plugin-posthtml-template?branch=master) Seamless integration between Rollup and PostHTML. ## Install ```bash $ npm i rollup-plugin-posthtml-template -D # or $ yarn add rollup-plugin-posthtml-template -D ``` ## Usage ```js // rollup.config.js import { join } from 'path'; import posthtml from 'rollup-plugin-posthtml-template'; export default { entry: join(__dirname, 'main.js'), dest: join(__dirname, 'bundle.js'), format: 'iife', plugins: [ posthtml() ] }; ``` ```html

Hello

World

``` ```js // main.js import hello from './hello.html'; document.querySelector('#ex').innerHTML = hello; /* Output:

Hello

World

*/ ``` ### plugins ```js // rollup.config.js import { join } from 'path'; import posthtml from 'rollup-plugin-posthtml-template'; import include from 'posthtml-include'; export default { entry: join(__dirname, 'main.js'), dest: join(__dirname, 'bundle.js'), format: 'iife', plugins: [ posthtml({ plugins: [include()] }) ] }; ``` ```html

World

``` ```html

Hello

``` ```js // main.js import hello from './hello.html'; document.querySelector('#ex').innerHTML = hello; /* Output:

Hello

World

*/ ``` ### template ```js // rollup.config.js import { join } from 'path'; import posthtml from 'rollup-plugin-posthtml-template'; export default { entry: join(__dirname, 'main.js'), dest: join(__dirname, 'bundle.js'), format: 'iife', plugins: [ posthtml({ template: true }) ] }; ``` ```html

Hello

${ _.text }

``` ```js // main.js import hello from './hello.html'; document.querySelector('#ex').innerHTML = hello({ text: 'World' }); /* Output:

Hello

World

*/ ``` ### parser ```js // rollup.config.js import { join } from 'path'; import posthtml from 'rollup-plugin-posthtml-template'; import sugarml from 'posthtml-sugarml'; export default { entry: join(__dirname, 'main.js'), dest: join(__dirname, 'bundle.js'), format: 'iife', plugins: [ posthtml({ parser: sugarml() }) ] }; ``` ```sgr // hello.sgr p Hello p | World ``` ```js // main.js import hello from './hello.sgr'; document.querySelector('#ex').innerHTML = hello; /* Output:

Hello

World

*/ ``` ### directives ```js // rollup.config.js import { join } from 'path'; import posthtml from 'rollup-plugin-posthtml-template'; export default { entry: join(__dirname, 'main.js'), dest: join(__dirname, 'bundle.js'), format: 'iife', plugins: [ posthtml({ directives: [{ name: '%', start: '<', end: '>' }] }) ] }; ``` ```html

Hello

<%= text %>

``` ```js // main.js import { template } from 'lodash'; import hello from './hello.html'; document.querySelector('#ex').innerHTML = template(hello)({ text: 'World' }); /* Output:

Hello

World

*/ ```