All Projects → sindresorhus → Gulp Template

sindresorhus / Gulp Template

Licence: mit
Render/precompile Lodash templates

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Template

Lodash Id
Makes it easy to manipulate id-based resources with lodash or lowdb
Stars: ✭ 434 (+57.25%)
Mutual labels:  lodash, underscore
Placeline Nextjs
HyperTrack Placeline web application sample using NextJS, Ant-Design, Styled-Components, and Heroku
Stars: ✭ 88 (-68.12%)
Mutual labels:  lodash, template
Sensei Grid
Simple and lightweight data grid in JS/HTML
Stars: ✭ 808 (+192.75%)
Mutual labels:  lodash, underscore
Javascript ninja
javascript-ninja 😆
Stars: ✭ 11 (-96.01%)
Mutual labels:  lodash, underscore
php-lodash
php-lodash is a PHP utility library, similar to Underscore/Lodash.
Stars: ✭ 35 (-87.32%)
Mutual labels:  lodash, underscore
underscore.haz
🔍 _.haz() is like _.has() but this underscore and/or lodash mixin lets you do deep object key existence checking with a dot denoted string, for example 'a.b.c'
Stars: ✭ 13 (-95.29%)
Mutual labels:  lodash, underscore
Dash
Functional programming library for PHP. Inspired by Underscore, Lodash, and Ramda.
Stars: ✭ 84 (-69.57%)
Mutual labels:  lodash, underscore
Nspl
Non-Standard PHP Library - functional primitives toolbox and more
Stars: ✭ 365 (+32.25%)
Mutual labels:  lodash, underscore
Gulp Nunjucks
Precompile Nunjucks templates
Stars: ✭ 143 (-48.19%)
Mutual labels:  gulp-plugin, template
Blog
若川的博客—学习源码整体架构系列8篇,前端面试高频源码,微信搜索「若川视野」关注我,长期交流学习~
Stars: ✭ 234 (-15.22%)
Mutual labels:  lodash, underscore
You Dont Need Lodash Underscore
List of JavaScript methods which you can use natively + ESLint Plugin
Stars: ✭ 13,915 (+4941.67%)
Mutual labels:  lodash, underscore
underwater
~2kb - ES6 Collection of helper functions. Lodash like
Stars: ✭ 18 (-93.48%)
Mutual labels:  lodash, underscore
rudash
Rudash - Lodash for Ruby Apps
Stars: ✭ 27 (-90.22%)
Mutual labels:  lodash, underscore
eslint-plugin-lodash-template
ESLint plugin for John Resig-style micro template, Lodash's template, Underscore's template and EJS.
Stars: ✭ 15 (-94.57%)
Mutual labels:  lodash, underscore
gulp-yaml
A Gulp plugin to convert YAML to JSON
Stars: ✭ 24 (-91.3%)
Mutual labels:  gulp-plugin
Hyperhtml
A Fast & Light Virtual DOM Alternative
Stars: ✭ 2,872 (+940.58%)
Mutual labels:  template
gulp-convert-encoding
Plugin for gulp to convert files from one encoding to another.
Stars: ✭ 15 (-94.57%)
Mutual labels:  gulp-plugin
Jekyll Theme Minimal Resume
Simple Jekyll theme for a minimal resume website: https://jekyll-theme-minimal-resume.netlify.com/
Stars: ✭ 269 (-2.54%)
Mutual labels:  template
Yii2 Gentelella
Free admin template for backend
Stars: ✭ 266 (-3.62%)
Mutual labels:  template
gulp-yarn
Automatically install node modules using Yarn. 😻
Stars: ✭ 22 (-92.03%)
Mutual labels:  gulp-plugin

gulp-template

Render/precompile Lodash/Underscore templates

Issues with the output should be reported on the Lodash issue tracker.

Install

$ npm install --save-dev gulp-template

Usage

src/greeting.html

<h1>Hello <%= name %></h1>

gulpfile.js

const gulp = require('gulp');
const template = require('gulp-template');

exports.default = () => (
	gulp.src('src/greeting.html')
		.pipe(template({name: 'Sindre'}))
		.pipe(gulp.dest('dist'))
);

You can alternatively use gulp-data to inject the data:

const gulp = require('gulp');
const template = require('gulp-template');
const data = require('gulp-data');

exports.default = () => (
	gulp.src('src/greeting.html')
		.pipe(data(() => ({name: 'Sindre'})))
		.pipe(template())
		.pipe(gulp.dest('dist'))
);

dist/greeting.html

<h1>Hello Sindre</h1>

API

template(data, options?)

Render a template using the provided data.

template.precompile(options?)

Precompile a template for rendering dynamically at a later time.

data

Type: object

Data object used to populate the text.

options

Type: object

Lodash _.template options.

Tip

You can also provide your own interpolation string for custom templates.

src/greeting.html

<h1>Hello {{ name }}</h1>

gulpfile.js

const gulp = require('gulp');
const template = require('gulp-template');
const data = require('gulp-data');

exports.default = () => (
	gulp.src('src/greeting.html')
		.pipe(data(() => ({name: 'Sindre'})))
		.pipe(template(null, {
			interpolate: /{{(.+?)}}/gs
		}))
		.pipe(gulp.dest('dist'))
);

dist/greeting.html

<h1>Hello Sindre</h1>

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].