Package Exports
- gulp-teddy
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-teddy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
gulp-teddy
Compiles Teddy templates
Install
$ npm install --save-dev gulp-teddyUsage
src/html/index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<title>Title</title>
</head>
<body>
<include src='templates/header.html'>
<arg mainTitle>Main title</arg>
</include>
</body>
</html>src/html/templates/header.html
<header>
<if mainTitle>
<h1>{mainTitle}</h1>
</if>
<else>
<p>No main title</p>
</else>
</header>gulpfile.js
var gulp = require('gulp'),
teddy = require('gulp-teddy');
teddy.settings({
setTemplateRoot: 'src/html/'
});
gulp.task('default', function() {
return gulp.src(['src/html/**/*.html','!src/html/templates/**/*.html'])
.pipe(teddy.compile())
.pipe(gulp.dest('dist'));
});dist/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width" />
<title>Title</title>
</head>
<body>
<header>
<h1>Main title</h1>
</header>
</body>
</html>Passing data
src/html/index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<title>Title</title>
</head>
<body>
<loop through='letters' val='letter'>
<p>{letter}</p>
</loop>
</body>
</html>gulpfile.js
var gulp = require('gulp'),
teddy = require('gulp-teddy');
teddy.settings({
setTemplateRoot: 'src/html/'
});
gulp.task('default', function() {
return gulp.src(['src/html/**/*.html', '!src/html/templates/**/*.html'])
.pipe(teddy.compile({
letters: ['a', 'b', 'c']
}))
.pipe(gulp.dest('dist'));
});dist/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width" />
<title>Title</title>
</head>
<body>
<p>a</p>
<p>b</p>
<p>c</p>
</body>
</html>API
teddy.settings(options)
options
Type: Object
{
setTemplateRoot: './',
setVerbosity: 0,
strictParser: false,
enableForeachTag: false,
compileAtEveryRender: false
}See the Teddy docs.
teddy.compile(data)
data (optional)
Type: Object
Notes
The compile method executes the original teddy.render() method with a template path and the optional data param. The original teddy.compile() method is not allowed, this plugin is for generating static html files with the help of the Teddy templating engine functionalities.