Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including gulp-ng-template-strings with all npm packages installed. Try it out:

var gulpNgTemplateStrings = require("gulp-ng-template-strings")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gulp-ng-template-strings v0.0.4

inline angular templates into directive definition objects


Inline angular templates into directive definition objects

Build Status Coverage Status npm version

Install | Example | API


npm i --save-dev gulp-ng-template-strings


Pass the plugin js files containing templateUrl properties to have them replaced with template properties.


var gulp = require('gulp');
var ngTemplateStrings = require('gulp-ng-template-strings');

gulp.task('default', function() {
  return gulp.src('src/**/*.js')

Input files


function tabDirective() {
    return {
        templateUrl: 'templates/tab.html'



Output file


function tabDirective() {
    return {
        templateUrl: '<ul><li>Tab</li></ul>'


All options can be passed on stream creation.



By default the plugin looks for files based of the file.cwd of each file passed through. This option overrides that for all files passed to a stream.

ngTemplateStrings({cwd: 'root/of/templatesUrls/'})


Your html strings will be minified with html-minifier. You can override our default configuration by passing a minify object in the settings object.

ngTemplateStrings({minify: {collapseWhitespace: false}})

By default we use the following options:

  removeComments: true, // remove html comments
  removeCommentsFromCDATA: true, // removes comments from inline JS & CSS
  collapseWhitespace: true, // collapse whitespace in text nodes
  caseSensitive: true // preserve case in attributes
  // all other options use html-minifier's default, false.

You can also disable minification altogether by passing:

ngTemplateStrings({minify: false})
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free