Skip to content

Inline file content (eg. HTML, CSS, or even other JS files) into JS files with Grunt.

License

Notifications You must be signed in to change notification settings

jhartikainen/grunt-inline2js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-inline2js

Inline file content (eg. HTML, CSS, or even other JS files) into JS files with Grunt.

You can use this to for example inline templates into your JS files, inline CSS, or pretty much anything else.

The plugin works by replacing a call to a template function with the contents of the file passed as its parameter.

var stuff = __tpl('path/to/file.html');

is turned into...

var stuff = 'contents of file are put here';

Task options

grunt.initConfig({
  inline2js: {
    options: {
      templateFunction: '__tpl'
    },
    files: {
      src: ['src/*.js'],
      dest: 'build/'
    }
  },
});

The templateFunction option defines which function name is used as the template function. Defaults to __tpl.

You define which files should be processed using the standard Grunt file syntax, as shown in the files attribute. Note: if destionation is a directory, full path names are kept for source files.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

About

Inline file content (eg. HTML, CSS, or even other JS files) into JS files with Grunt.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages