Repository: karlgoldstein/grunt-html2js
Branch: master
Commit: 839f87428464
Files: 79
Total size: 75.9 KB
Directory structure:
gitextract_mrc6b39g/
├── .gitattributes
├── .github/
│ └── workflows/
│ └── semgrep.yml
├── .gitignore
├── .jshintrc
├── .travis.yml
├── Gruntfile.js
├── LICENSE-MIT
├── README.md
├── package.json
├── tasks/
│ └── html2js.js
└── test/
├── expected/
│ ├── amd_module.js
│ ├── amd_module_custom_prefix.js
│ ├── amd_module_custom_suffix.js
│ ├── broken_newlines.js
│ ├── coffee.coffee
│ ├── compact_format_custom_options.js
│ ├── compact_format_default_options.js
│ ├── custom_attribute_collapsed.js
│ ├── custom_attribute_not_collapsed.js
│ ├── double_quotes.js
│ ├── empty_attribute.js
│ ├── existing_module.js
│ ├── file_footer.js
│ ├── file_header.js
│ ├── file_header_footer.js
│ ├── files_array_custom_options_1.js
│ ├── files_array_custom_options_2.js
│ ├── files_array_default_options_1.js
│ ├── files_array_default_options_2.js
│ ├── files_object_custom_options_1.js
│ ├── files_object_custom_options_2.js
│ ├── files_object_default_options_1.js
│ ├── files_object_default_options_2.js
│ ├── htmlmin.js
│ ├── issue_26_withCollapseWhitespaceFalseDefaultQuotes.js
│ ├── issue_26_withCollapseWhitespaceFalseDoubleQuotes.js
│ ├── issue_26_withCollapseWhitespaceFalseSingleQuotes.js
│ ├── issue_26_withCollapseWhitespaceTrueDefaultQuotes.js
│ ├── issue_26_withCollapseWhitespaceTrueDoubleQuotes.js
│ ├── issue_26_withCollapseWhitespaceTrueSingleQuotes.js
│ ├── issue_26_withoutCollapseWhitespaceDefaultQuotes.js
│ ├── issue_26_withoutCollapseWhitespaceDoubleQuotes.js
│ ├── issue_26_withoutCollapseWhitespaceSingleQuotes.js
│ ├── module_as_function.js
│ ├── multi_lines.js
│ ├── multi_lines_4spaces.js
│ ├── multi_lines_tabs.js
│ ├── process_all_pug.js
│ ├── process_all_pug_after_change.js
│ ├── process_function.js
│ ├── process_pug.js
│ ├── process_pug_custom.js
│ ├── process_pug_with_include.js
│ ├── process_template.js
│ ├── regex_in_template.js
│ ├── rename.js
│ ├── single_module.coffee
│ ├── single_module.js
│ ├── single_module_strict.js
│ ├── single_quotes.js
│ ├── strict_mode.js
│ └── template_path_in_comment.js
├── fixtures/
│ ├── broken_newlines.tpl.html
│ ├── custom_attribute_collapse.tpl.html
│ ├── empty_attribute.tpl.html
│ ├── five.tpl.html
│ ├── four.tpl.html
│ ├── issue_26.tpl.html
│ ├── one.tpl.html
│ ├── pattern.tpl.html
│ ├── process_function.tpl.html
│ ├── process_pug.pug
│ ├── process_pug_custom.pug
│ ├── process_pug_with_include.pug
│ ├── process_template.tpl.html
│ ├── pug_include.pug
│ ├── three.tpl.html
│ └── two.tpl.html
└── html2js_test.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# this file has broken newlines, and we want it to stay this way
broken_newlines.tpl.html binary
================================================
FILE: .github/workflows/semgrep.yml
================================================
on:
pull_request: {}
push:
branches:
- main
- master
paths:
- .github/workflows/semgrep.yml
schedule:
- cron: '0 0 * * 0'
name: Semgrep
jobs:
semgrep:
name: Scan
runs-on: ubuntu-20.04
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
container:
image: returntocorp/semgrep
steps:
- uses: actions/checkout@v3
- run: semgrep ci
================================================
FILE: .gitignore
================================================
node_modules
npm-debug.log
tmp
coverage
================================================
FILE: .jshintrc
================================================
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true,
"es5": true
}
================================================
FILE: .travis.yml
================================================
language: node_js
sudo: false
node_js:
- 10
- 11
- 12
- 13
- 14
- 15
install:
- npm install
before_script:
- npm install grunt-cli istanbul
script:
- ./node_modules/.bin/istanbul cover ./node_modules/.bin/grunt test
- ./node_modules/.bin/grunt coveralls
================================================
FILE: Gruntfile.js
================================================
/*
* grunt-html2js
* https://github.com/rquadling/grunt-html2js
*
* Copyright (c) 2013 Karl Goldstein
* Copyright (c) 2017 Richard Quadling
*
* Licensed under the MIT license.
*/
'use strict';
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
coveralls: {
// Options relevant to all targets
options: {
// When true, grunt-coveralls will only print a warning rather than
// an error, to prevent CI builds from failing unnecessarily (e.g. if
// coveralls.io is down). Optional, defaults to false.
force: false
},
html2js: {
// LCOV coverage file (can be string, glob or array)
src: 'coverage/lcov.info',
options: {
// Any options for just this target
}
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>'
]
},
// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp']
},
// Configuration to be run (and then tested).
// See https://github.com/gruntjs/grunt/wiki/Configuring-tasks
// for configuration options that need to be tested
html2js: {
amd_module: {
options: {
amd: true,
quoteChar: '\''
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/amd_module.js'
},
amd_module_custom_prefix: {
options: {
amd: true,
amdPrefixString: 'define([\'ng\'], function(angular){'
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/amd_module_custom_prefix.js'
},
amd_module_custom_suffix: {
options: {
amd: true,
amdSuffixString: '}); //Custom!'
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/amd_module_custom_suffix.js'
},
broken_newlines: {
src: ['test/fixtures/broken_newlines.tpl.html'],
dest: 'tmp/broken_newlines.js'
},
coffee: {
options: {
target: 'coffee'
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/coffee.coffee'
},
compact_format_custom_options: {
options: {
base: 'test',
module: 'my-custom-template-module'
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/compact_format_custom_options.js'
},
compact_format_default_options: {
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/compact_format_default_options.js'
},
custom_attribute_collapsed: {
src: ['test/fixtures/custom_attribute_collapse.tpl.html'],
dest: 'tmp/custom_attribute_collapsed.js',
options: {
htmlmin: {
customAttrCollapse: /my-[a-z]*/
}
}
},
custom_attribute_not_collapsed: {
src: ['test/fixtures/custom_attribute_collapse.tpl.html'],
dest: 'tmp/custom_attribute_not_collapsed.js'
},
double_quotes: {
src: ['test/fixtures/four.tpl.html'],
dest: 'tmp/double_quotes.js'
},
empty_attribute: {
src: ['test/fixtures/empty_attribute.tpl.html'],
dest: 'tmp/empty_attribute.js'
},
empty_module: {
src: [],
dest: 'tmp/empty_module.js'
},
existing_module: {
options: {
singleModule: true,
existingModule: true
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/three.tpl.html'],
dest: 'tmp/existing_module.js'
},
file_footer: {
options: {
fileFooterString: '/* Module End */\n'
},
src: ['test/fixtures/three.tpl.html'],
dest: 'tmp/file_footer.js'
},
file_header: {
options: {
fileHeaderString: '/* Module Start */\n'
},
src: ['test/fixtures/three.tpl.html'],
dest: 'tmp/file_header.js'
},
file_header_footer: {
options: {
fileHeaderString: '/* Module Start */\n',
fileFooterString: '/* Module End */\n'
},
src: ['test/fixtures/three.tpl.html'],
dest: 'tmp/file_header_footer.js'
},
files_array_custom_options: {
options: {
base: 'test',
module: 'my-custom-template-module'
},
files: [
{
dest: 'tmp/files_array_custom_options_1.js',
src: ['test/fixtures/one.tpl.html'],
module: 'my-custom-templates'
},
{
dest: 'tmp/files_array_custom_options_2.js',
src: ['test/fixtures/two.tpl.html'],
module: 'my-custom-templates'
}
]
},
files_array_default_options: {
files: [
{
dest: 'tmp/files_array_default_options_1.js',
src: ['test/fixtures/one.tpl.html']
},
{
dest: 'tmp/files_array_default_options_2.js',
src: ['test/fixtures/two.tpl.html']
}
]
},
files_object_custom_options: {
options: {
base: 'test',
module: 'my-custom-template-module'
},
files: {
'tmp/files_object_custom_options_1.js': ['test/fixtures/one.tpl.html'],
'tmp/files_object_custom_options_2.js': ['test/fixtures/two.tpl.html']
}
},
files_object_default_options: {
files: {
'tmp/files_object_default_options_1.js': ['test/fixtures/one.tpl.html'],
'tmp/files_object_default_options_2.js': ['test/fixtures/two.tpl.html']
}
},
htmlmin: {
options: {
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
},
src: ['test/fixtures/five.tpl.html'],
dest: 'tmp/htmlmin.js'
},
issue_26_withCollapseWhitespaceFalseDefaultQuotes: {
options: {
htmlmin: {
collapseWhitespace: false
}
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withCollapseWhitespaceFalseDefaultQuotes.js'
},
issue_26_withCollapseWhitespaceFalseDoubleQuotes: {
options: {
htmlmin: {
collapseWhitespace: false
},
quoteChar: '"'
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withCollapseWhitespaceFalseDoubleQuotes.js'
},
issue_26_withCollapseWhitespaceFalseSingleQuotes: {
options: {
htmlmin: {
collapseWhitespace: false
},
quoteChar: '\''
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withCollapseWhitespaceFalseSingleQuotes.js'
},
issue_26_withCollapseWhitespaceTrueDefaultQuotes: {
options: {
htmlmin: {
collapseWhitespace: false
}
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withCollapseWhitespaceTrueDefaultQuotes.js'
},
issue_26_withCollapseWhitespaceTrueDoubleQuotes: {
options: {
htmlmin: {
collapseWhitespace: false
},
quoteChar: '"'
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withCollapseWhitespaceTrueDoubleQuotes.js'
},
issue_26_withCollapseWhitespaceTrueSingleQuotes: {
options: {
htmlmin: {
collapseWhitespace: false
},
quoteChar: '\''
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withCollapseWhitespaceTrueSingleQuotes.js'
},
issue_26_withoutCollapseWhitespaceDefaultQuotes: {
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withoutCollapseWhitespaceDefaultQuotes.js'
},
issue_26_withoutCollapseWhitespaceDoubleQuotes: {
options: {
quoteChar: '"'
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withoutCollapseWhitespaceDoubleQuotes.js'
},
issue_26_withoutCollapseWhitespaceSingleQuotes: {
options: {
quoteChar: '\''
},
src: ['test/fixtures/issue_26.tpl.html'],
dest: 'tmp/issue_26_withoutCollapseWhitespaceSingleQuotes.js'
},
issue_76_missingSourceFile: {
nonull: true,
src: 'test/fixtures/issue_76_missing.tpl.html',
dest: 'tmp/issue_76_missingSourceFile.js'
},
issue_76_missingSourceFiles: {
nonull: true,
src: ['test/fixtures/issue_76_missing_1.tpl.html', 'test/fixtures/issue_76_missing_2.tpl.html'],
dest: 'tmp/issue_76_missingSourceFiles.js'
},
issue_76_missingSourceFilesFirst: {
nonull: true,
src: ['test/fixtures/issue_76_missing_1.tpl.html', 'test/fixtures/one.tpl.html'],
dest: 'tmp/issue_76_missingSourceFilesFirst.js'
},
issue_76_missingSourceFilesLast: {
nonull: true,
src: ['test/fixtures/one.tpl.html', 'test/fixtures/issue_76_missing_1.tpl.html'],
dest: 'tmp/issue_76_missingSourceFilesLast.js'
},
issue_76_missingSourceFilesMiddle: {
nonull: true,
src: ['test/fixtures/one.tpl.html', 'test/fixtures/issue_76_missing_1.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/issue_76_missingSourceFilesMiddle.js'
},
module_as_function: {
options: {
module: function (file) {
return 'NAME_FROM_FUNCTION';
}
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/module_as_function.js'
},
multi_lines: {
src: ['test/fixtures/three.tpl.html'],
dest: 'tmp/multi_lines.js'
},
multi_lines_4space: {
options: {
indentString: ' '
},
src: ['test/fixtures/three.tpl.html'],
dest: 'tmp/multi_lines_4spaces.js'
},
multi_lines_tabs: {
options: {
indentString: '\t'
},
src: ['test/fixtures/three.tpl.html'],
dest: 'tmp/multi_lines_tabs.js'
},
process_all_pug: {
options: {
pug: {},
watch: true
},
src: ['test/fixtures/*.pug'],
dest: 'tmp/process_all_pug.js'
},
process_function: {
options: {
process: function (html, filePath) {
html = html.replace('(ONE)', '1');
html = html.replace('(TWO)', '2');
html = html.replace('(THREE)', '3');
return html;
}
},
src: ['test/fixtures/process_function.tpl.html'],
dest: 'tmp/process_function.js'
},
process_pug: {
src: ['test/fixtures/process_pug.pug'],
dest: 'tmp/process_pug.js'
},
process_pug_custom: {
options: {
pug: {doctype: 'html'}
},
src: ['test/fixtures/process_pug_custom.pug'],
dest: 'tmp/process_pug_custom.js'
},
process_pug_with_include: {
options: {
pug: {}
},
src: ['test/fixtures/process_pug_with_include.pug'],
dest: 'tmp/process_pug_with_include.js'
},
process_template: {
testMessages: {
title: 'Main Title',
subtitle: 'Subtitle with {{ interpolation }}'
},
options: {
process: true
},
src: ['test/fixtures/process_template.tpl.html'],
dest: 'tmp/process_template.js'
},
regex_in_template: {
src: ['test/fixtures/pattern.tpl.html'],
dest: 'tmp/regex_in_template.js'
},
rename: {
options: {
rename: function (moduleName) {
return moduleName.replace('.html', '');
}
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/two.tpl.html'],
dest: 'tmp/rename.js'
},
single_module: {
options: {
singleModule: true
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/three.tpl.html'],
dest: 'tmp/single_module.js'
},
single_module_strict: {
options: {
singleModule: true,
useStrict: true
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/three.tpl.html'],
dest: 'tmp/single_module_strict.js'
},
single_module_coffee: {
options: {
singleModule: true,
target: 'coffee'
},
src: ['test/fixtures/one.tpl.html', 'test/fixtures/three.tpl.html'],
dest: 'tmp/single_module.coffee'
},
single_quotes: {
options: {
quoteChar: '\''
},
src: ['test/fixtures/four.tpl.html'],
dest: 'tmp/single_quotes.js'
},
strict_mode: {
options: {
useStrict: true
},
src: ['test/fixtures/one.tpl.html'],
dest: 'tmp/strict_mode.js'
},
template_path_in_comment: {
options: {
templatePathInComment: true
},
src: ['test/fixtures/three.tpl.html'],
dest: 'tmp/template_path_in_comment.js'
}
},
// Unit tests.
nodeunit: {
tests: ['test/*_test.js']
}
});
// Actually load this plugin's task(s).
grunt.loadTasks('tasks');
// These plugins provide necessary tasks.
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'html2js', 'nodeunit']);
// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);
};
================================================
FILE: LICENSE-MIT
================================================
Copyright (c) 2013 Karl Goldstein
Copyright (c) 2017-2021 Richard Quadling
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
[](https://travis-ci.org/rquadling/grunt-html2js)
[](https://coveralls.io/github/rquadling/grunt-html2js)
[](https://www.npmjs.com/package/grunt-html2js)
[](https://www.npmjs.com/package/grunt-html2js)
[](https://www.npmjs.com/package/grunt-html2js)
[](https://www.npmjs.com/package/grunt-html2js)
[](https://www.npmjs.com/package/grunt-html2js)
# grunt-html2js
Converts AngularJS templates to JavaScript
## Getting Started
This plugin requires Grunt v1 or later
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started)
guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins.
Once you're familiar with that process, you may install this plugin with this command:
```shell
npm install grunt-html2js --save-dev
```
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
```js
grunt.loadNpmTasks('grunt-html2js');
```
## The "html2js" task
### Overview
Angular-JS normally loads templates lazily from the server as you reference them in your application (via `ng-include`, routing
configuration or other mechanism). Angular caches the source code for each template so that subsequent references do not require
another server request. However, if your application is divided into many small components, then the initial loading process may
involve an unacceptably large number of additional server requests.
This plugin converts a group of templates to JavaScript and assembles them into an Angular module that primes the cache directly
when the module is loaded. You can concatenate this module with your main application code so that Angular does not need to make
any additional server requests to initialize the application.
Note that this plugin does *not* compile the templates. It simply caches the template source code.
### Setup
By default, this plugin assumes you are following the naming conventions and build pipeline of the [angular-app](https://github.com/angular-app/angular-app)
demo application.
In your project's Gruntfile, add a section named `html2js` to the data object passed into `grunt.initConfig()`.
This simplest configuration will assemble all templates in your src tree into a module named `templates-main`, and write the
JavaScript source for the module to `tmp/template.js`:
```js
grunt.initConfig({
html2js: {
options: {
// custom options, see below
},
main: {
src: ['src/**/*.tpl.html'],
dest: 'tmp/templates.js'
},
},
})
```
Assuming you concatenate the resulting file with the rest of your application code, you can then specify the module as a
dependency in your code:
```
angular.module('main', ['templates-main'])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/somepath', {
templateUrl:'some/template.tpl.html',
```
Note that you should use relative paths to specify the template URL, to
match the keys by which the template source is cached.
### Gotchas
The `dest` property must be a string. If it is an array, Grunt will fail when attempting to write the bundle file.
### Options
#### options.base
Type: `String`
Default value: `'src'`
The prefix relative to the project directory that should be stripped from each template path to produce a module identifier for
the template. For example, a template located at `src/projects/projects.tpl.html` would be identified as just
`projects/projects.tpl.html`.
#### options.target
Type: `String`
Default value: `'js'`
Language of the output file. Possible values: `'coffee'`, `'js'`.
#### options.module
Type: `String` or `Function`
Default value: `templates-TARGET`
The name of the parent Angular module for each set of templates. Defaults to the task target prefixed by `templates-`.
The value of this argument can be a string or a function. The function should expect the module file path and grunt task name
as arguments, and it should return the name to use for the parent Angular module.
If no bundle module is desired, set this to false.
#### options.rename
Type: `Function`
Default value: `none`
A function that takes in the module identifier and returns the renamed module identifier to use instead for the template. For
example, a template located at `src/projects/projects.tpl.html` would be identified as `/src/projects/projects.tpl` with a
rename function defined as:
```
function (moduleName) {
return '/' + moduleName.replace('.html', '');
}
```
#### options.quoteChar
Type: `Character`
Default value: `"`
Strings are quoted with double-quotes by default. However, for projects
that want strict single quote-only usage, you can specify:
```
options: { quoteChar: '\'' }
```
to use single quotes, or any other odd quoting character you want
#### options.indentString
Type: `String`
Default value: ` `
By default a 2-space indent is used for the generated code. However,
you can specify alternate indenting via:
```
options: { indentString: ' ' }
```
to get, for example, 4-space indents. Same goes for tabs or any other
indent system you want to use.
#### options.fileHeaderString:
Type: `String`
Default value: ``
If specified, this string will get written at the top of the output
Template.js file. As an example, jshint directives such as
/* global angular: false */ can be put at the head of the file.
#### options.fileFooterString:
Type: `String`
Default value: ``
If specified, this string will get written at the end of the output
file. May be used in conjunction with `fileHeaderString` to wrap
the output.
#### options.useStrict:
Type: `Boolean`
Default value: ``
If set true, each module in JavaScript will have 'use strict'; written at the top of the
module. Useful for global strict jshint settings.
```
options: { useStrict: true }
```
#### options.htmlmin:
Type: `Object`
Default value: {}
Minifies HTML using [html-minifier](https://github.com/kangax/html-minifier).
```
options: {
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
}
```
In addition, the `customAttrCollapse` option is supported, allowing you to supply a regex that
is used to match attribute names in which multiple whitespace will be collapsed to a single space.
#### options.process:
Type: `Object` or `Boolean` or `Function`
Default value: `false`
Performs arbitrary processing on the template as part of the compilation process.
Option value can be one of:
1. a function that accepts `content` and `filepath` as arguments, and returns the transformed content
2. an object that is passed as the second options argument to `grunt.template.process` (with the file content as the first
argument)
3. `true` to call `grunt.template.process` with the content and no options
#### options.singleModule
Type: `Boolean`
Default value: `false`
If set to true, will create a single wrapping module with a run block, instead of an individual module for each template file.
Requires that the `module` option is not falsy.
#### options.existingModule
Type: `Boolean`
Default value: `false`
If set to true, will use an existing module with the name from `module`, instead of creating a new module. Requires that
`singleModule` is not falsy.
#### options.watch
Type: `Boolean`
Default value: `false`
If set to true and used in conjunction with a long running/keep-alive process such as grunt-contrib-watch html2js will watch src
files for changes and regenerate output to dest. It uses an internal cache so only the file that changes needs to be
re-compliled. Useful for development process particularly if you have lots of pug templates. It is very similar to
grunt-browserify's watch.
```
options: {
pug: {},
watch: true
}
```
N.B. If using grunt-watch you do not need to run the html2js task again on src changes as it watches internally for these. All
you need to do is watch the destination file and live reload on change.
#### options.amd
Type: `Boolean`
Default value: `false`
If set to true, will wrap output in a define block so it is compatible with AMD module loaders such as RequireJS without
requiring you to shim the module.
#### options.amdPrefixString
Type: `String`
Default value: `define(['angular'], function(angular){\n`
When `options.amd` is set to true, this is what will be prepended to the module to make it compatible with AMD module loaders.
Along with `amdSuffixString`, these two options should allow you to customize the way your AMD module is created.
#### options.amdSuffixString
Type: `String`
Default Value: `});`
When `options.amd` is set to true, this is what will be postpended to the module to make it compatible with AMD module loaders.
Along with `amdPrefixString`, these two options should allow you to customize the way your AMD module is created.
### Pug support
#### options.pug
If template filename ends with `.pug` the task will automatically render file's content using [Pug](https://github.com/pugjs/pug)
then compile into JS.
Options can be passed to Pug within a `pug` property in the plugin options.
```
options: {
pug: {
//this prevents auto expansion of empty arguments
//e.g. "div(ui-view)" becomes "<div ui-view></div>"
// instead of "<div ui-view="ui-view"></div>"
doctype: "html"
}
}
```
#### options.templatePathInComment:
Type: `Boolean`
Default value: `false`
If specified, adds an HTML comment containing the template file path as a comment at the start of each template.
### Usage Examples
See the `Gruntfile.js` in the project source code for various configuration examples.
## 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](http://gruntjs.com/).
## Release History
0.1.1 Build module even if templates do not exist yet
0.1.2 Preserve line feeds in templates to avoid breaking <pre>-formatted text
0.1.3 Add option to set the `module` option to null to disable creation of bundle module
0.1.4 Add rename option
0.1.5 Add config options for quoteChar, indentString and fileHeaderString (thanks @jonathana)
0.1.6 Add support for CoffeeScript (thanks @srigi)
0.1.7 Escape backslashes in template source (issue #11, thanks @JoakimBe)
0.1.8 Add fileFooterString option (issue #13, thanks @duro)
0.1.9 Add useStrict option (pull request #15, thanks @marcoose)
0.2.0 Add htmlmin option (pull request #16, thanks @buberdds)
0.2.1 Fix dependencies for htmlmin (pull request #17, vielen dank @mlegenhausen)
0.2.2 Fix counter of converted files (pull request #18, thanks @srigi)
0.2.3 Add option to interpret 'module' as function (pull request #20, thanks @CodingGorilla)
0.2.4 Add `process` option (pull request #24, thanks @scottrippey)
0.2.5 Add task name as argument to function variant of module option (pull request #37, thanks @lukovnikov)
0.2.6 Add support for auto-detecting Jade templates as input (thanks @bahmutov)
0.2.7 Add singleModule module for placing all templates in a single module (PR #43, thanks @janeklb)
0.2.8 Allow passing option to Jade templates (PR #46, thanks @NickClark)
0.2.9 Support relative file names for Jade templates (PR #48, thanks @dvonlehman)
0.3.0 Allow use strict in single mode (PR #58, thanks @mfeckie)
0.3.1 Add watch feature (PR #67, thanks @startswithaj)
0.3.2 Update to stable chokidar (PR #68, thanks @paulmillr)
0.3.3 Fix dependency on jade (PR #72, thanks @mathewleon)
0.3.4 Add existingModule option (PR #75, thanks @Jandalf)
0.3.5 Adds options to support AMD modules (PR #75, thanks @Southpaw17)
0.3.6 Updates peer dependencies for Grunt 1.0 (PR #81)
0.3.7 Fix dependencies for htmlmin
As of 0.3.7, this package is now administered by Richard Quadling who gives a big "Thank you" to Karl for his hard work.
0.3.8 Fix broken newlines (\r\r\n)
0.4.0 Added ability to render pug templates. Maintains Backwards compatibility. (#83)
Marked support for jade templates as deprecated. Support will be removed in 0.5.0
0.4.1 Added ability to add an HTML comment to the templates (#9/#10)
0.4.2 Empty modules not generated if no source files located (#55)
0.5.0 Introduce Travis CI for unit tests and code coverage.
Removed support for Jade.
Added badges.
Reformatted code and README.md.
0.5.1 Fix options.quoteChar usage for module header (#64)
0.6.0 Upgraded dependencies to latest versions.`npm audit` shows 0 vulnerabilities.
0.7.0 Upgraded dependencies to latest versions.`npm audit` shows 0 vulnerabilities.
0.8.0 Upgraded dependencies to latest versions.`npm audit` shows 0 vulnerabilities.
0.9.0 Removed `istanbul` as a dependency as it is only used during testing.
================================================
FILE: package.json
================================================
{
"name": "grunt-html2js",
"description": "Compiles AngularJS templates to JavaScript",
"version": "0.9.0",
"homepage": "https://github.com/rquadling/grunt-html2js",
"author": {
"name": "Karl Goldstein",
"email": "karl.goldstein@gmail.com"
},
"contributors": [
{
"name": "Richard Quadling",
"email": "RQuadling@GMail.com"
}
],
"repository": {
"type": "git",
"url": "https://github.com/rquadling/grunt-html2js.git"
},
"bugs": {
"url": "https://github.com/rquadling/grunt-html2js/issues"
},
"license": "SEE LICENSE IN LICENSE-MIT",
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.10.0"
},
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"grunt": "^1.5.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-nodeunit": "^4",
"grunt-coveralls": "^2",
"load-grunt-tasks": "^5",
"minimist": "^1.2.7"
},
"peerDependencies": {
"grunt": ">=0.4.0"
},
"optionalDependencies": {
"pug": "^3"
},
"keywords": [
"gruntplugin"
],
"dependencies": {
"chokidar": "^3.5.3",
"grunt-cli": "^1.3.2",
"html-minifier": "^4",
"minimist": "^1.2.7"
}
}
================================================
FILE: tasks/html2js.js
================================================
/*
* grunt-html2js
* https://github.com/rquadling/grunt-html2js
*
* Copyright (c) 2013 Karl Goldstein
* Copyright (c) 2017 Richard Quadling
*
* Licensed under the MIT license.
*/
'use strict';
module.exports = function (grunt) {
var path = require('path');
var minify = require('html-minifier').minify;
var escapeContent = function (content, quoteChar, indentString, pathToAddAsComment) {
content = (pathToAddAsComment ? '<!-- template: ' + pathToAddAsComment + ' -->\n' : '') + content;
var bsRegexp = new RegExp('\\\\', 'g');
var quoteRegexp = new RegExp('\\' + quoteChar, 'g');
var nlReplace = '\\n' + quoteChar + ' +\n' + indentString + indentString + quoteChar;
return content.replace(bsRegexp, '\\\\').replace(quoteRegexp, '\\' + quoteChar).replace(/\r*\n/g, nlReplace);
};
// convert Windows file separator URL path separator
var normalizePath = function (p) {
if (path.sep !== '/') {
p = p.replace(/\\/g, '/');
}
return p;
};
// Warn on and remove invalid source files (if nonull was set).
var existsFilter = function (filepath) {
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
};
function isPugTemplate (filepath) {
var pugExtension = /\.pug$/;
return pugExtension.test(filepath);
}
// return template content
var getContent = function (filepath, options) {
var content = grunt.file.read(filepath);
if (isPugTemplate(filepath)) {
var pug = require('pug');
options.pug.filename = filepath;
content = pug.render(content, options.pug);
}
// Process files as templates if requested.
var process = options.process;
if (typeof process === 'function') {
content = process(content, filepath);
} else if (process) {
if (process === true) {
process = {};
}
content = grunt.template.process(content, process);
}
if (Object.keys(options.htmlmin).length) {
try {
content = minify(content, options.htmlmin);
} catch (err) {
grunt.warn(filepath + '\n' + err);
}
}
// trim leading whitespace
content = content.replace(/(^\s*)/g, '');
return escapeContent(content, options.quoteChar, options.indentString, options.templatePathInComment ? filepath : '');
};
// compile a template to an angular module
var compileTemplate = function (moduleName, filepath, options) {
var quoteChar = options.quoteChar;
var indentString = options.indentString;
var withModule = !options.singleModule;
var content = getContent(filepath, options);
var doubleIndent = indentString + indentString;
var strict = (options.useStrict) ? indentString + quoteChar + 'use strict' + quoteChar + ';\n' : '';
var compiled = '';
if (withModule) {
compiled += 'angular.module(' + quoteChar + moduleName +
quoteChar + ', []).run([' + quoteChar + '$templateCache' + quoteChar + ', function($templateCache) {\n' + strict;
}
compiled += indentString + '$templateCache.put(' + quoteChar + moduleName + quoteChar +
',\n' + doubleIndent + quoteChar + content + quoteChar + ');';
if (withModule) {
compiled += '\n}]);\n';
}
return compiled;
};
// compile a template to an angular module
var compileCoffeeTemplate = function (moduleName, filepath, options) {
var quoteChar = options.quoteChar;
var indentString = options.indentString;
var withModule = !options.singleModule;
var content = getContent(filepath, options);
var doubleIndent = indentString + indentString;
var compiled = '';
if (withModule) {
compiled += 'angular.module(' + quoteChar + moduleName +
quoteChar + ', []).run([' + quoteChar + '$templateCache' + quoteChar + ', ($templateCache) ->\n';
}
compiled += indentString + '$templateCache.put(' + quoteChar + moduleName + quoteChar +
',\n' + doubleIndent + quoteChar + content + quoteChar + ')';
if (withModule) {
compiled += '\n])\n';
}
return compiled;
};
grunt.registerMultiTask('html2js', 'Compiles Angular-JS templates to JavaScript.', function () {
var options = this.options({
base: 'src',
module: 'templates-' + this.target,
quoteChar: '"',
fileHeaderString: '',
fileFooterString: '',
indentString: ' ',
target: 'js',
htmlmin: {},
process: false,
pug: {pretty: true},
singleModule: false,
existingModule: false,
watch: false,
amd: false,
amdPrefixString: 'define([\'angular\'], function(angular){',
amdSuffixString: '});',
templatePathInComment: false
});
var counter = 0;
var target = this.target;
var fileCache = {};
var watcher = null;
// generate a separate module
function generateModule (f) {
// f.dest must be a string or write will fail
var moduleNames = [];
var filePaths = f.src.filter(existsFilter);
if (options.watch) {
watcher.add(filePaths);
}
var modules = filePaths.map(function (filepath) {
var moduleName = normalizePath(path.relative(options.base, filepath));
if (grunt.util.kindOf(options.rename) === 'function') {
moduleName = options.rename(moduleName);
}
moduleNames.push(options.quoteChar + moduleName + options.quoteChar);
var compiled;
if (options.watch && (compiled = fileCache[filepath])) {
// return compiled file contents from cache
return compiled;
}
if (options.target === 'js') {
compiled = compileTemplate(moduleName, filepath, options);
} else if (options.target === 'coffee') {
compiled = compileCoffeeTemplate(moduleName, filepath, options);
} else {
grunt.fail.fatal('Unknown target "' + options.target + '" specified');
}
if (options.watch) {
// store compiled file contents in cache
fileCache[filepath] = compiled;
}
return compiled;
});
// don't generate empty modules
if (!modules.length) {
return;
}
counter += modules.length;
modules = modules.join('\n');
var fileHeader = options.fileHeaderString !== '' ? options.fileHeaderString + '\n' : '';
var fileFooter = options.fileFooterString !== '' ? options.fileFooterString + '\n' : '';
var bundle = '';
var targetModule = f.module || options.module;
var indentString = options.indentString;
var quoteChar = options.quoteChar;
var strict = (options.useStrict) ? indentString + quoteChar + 'use strict' + quoteChar + ';\n' : '';
var amdPrefix = '';
var amdSuffix = '';
// If options.module is a function, use that to get the targetModule
if (grunt.util.kindOf(targetModule) === 'function') {
targetModule = targetModule(f, target);
}
if (options.amd) {
amdPrefix = options.amdPrefixString;
amdSuffix = options.amdSuffixString;
}
if (!targetModule && options.singleModule) {
throw new Error('When using singleModule: true be sure to specify a (target) module');
}
if (options.existingModule && !options.singleModule) {
throw new Error('When using existingModule: true be sure to set singleModule: true');
}
if (options.singleModule) {
var moduleSuffix = options.existingModule ? '' : ', []';
if (options.target === 'js') {
bundle = 'angular.module(' + quoteChar + targetModule + quoteChar + moduleSuffix + ').run([' + quoteChar + '$templateCache' + quoteChar + ', function($templateCache) {\n' + strict;
modules += '\n}]);\n';
} else if (options.target === 'coffee') {
bundle = 'angular.module(' + quoteChar + targetModule + quoteChar + moduleSuffix + ').run([' + quoteChar + '$templateCache' + quoteChar + ', ($templateCache) ->\n';
modules += '\n])\n';
}
} else if (targetModule) {
//Allow a 'no targetModule if module is null' option
bundle = 'angular.module(' + quoteChar + targetModule + quoteChar + ', [' + moduleNames.join(', ') + '])';
if (options.target === 'js') {
bundle += ';';
}
bundle += '\n\n';
}
grunt.file.write(f.dest, grunt.util.normalizelf(fileHeader + amdPrefix + bundle + modules + amdSuffix + fileFooter));
}
if (options.watch) {
var files = this.files;
var chokidar = require('chokidar');
watcher = chokidar.watch().on('change', function (filepath) {
// invalidate cache
fileCache[filepath] = null;
// regenerateModules
files.forEach(generateModule);
});
}
this.files.forEach(generateModule);
//Just have one output, so if we are making thirty files it only does one line
grunt.log.writeln('Successfully converted ' + ('' + counter).green +
' html templates to ' + options.target + '.');
});
};
================================================
FILE: test/expected/amd_module.js
================================================
define(['angular'], function(angular){angular.module('templates-amd_module', ['../test/fixtures/one.tpl.html', '../test/fixtures/two.tpl.html']);
angular.module('../test/fixtures/one.tpl.html', []).run(['$templateCache', function($templateCache) {
$templateCache.put('../test/fixtures/one.tpl.html',
'1 2 3');
}]);
angular.module('../test/fixtures/two.tpl.html', []).run(['$templateCache', function($templateCache) {
$templateCache.put('../test/fixtures/two.tpl.html',
'Testing');
}]);
});
================================================
FILE: test/expected/amd_module_custom_prefix.js
================================================
define(['ng'], function(angular){angular.module("templates-amd_module_custom_prefix", ["../test/fixtures/one.tpl.html", "../test/fixtures/two.tpl.html"]);
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
}]);
angular.module("../test/fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/two.tpl.html",
"Testing");
}]);
});
================================================
FILE: test/expected/amd_module_custom_suffix.js
================================================
define(['angular'], function(angular){angular.module("templates-amd_module_custom_suffix", ["../test/fixtures/one.tpl.html", "../test/fixtures/two.tpl.html"]);
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
}]);
angular.module("../test/fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/two.tpl.html",
"Testing");
}]);
}); //Custom!
================================================
FILE: test/expected/broken_newlines.js
================================================
angular.module("templates-broken_newlines", ["../test/fixtures/broken_newlines.tpl.html"]);
angular.module("../test/fixtures/broken_newlines.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/broken_newlines.tpl.html",
"abc\n" +
"def");
}]);
================================================
FILE: test/expected/coffee.coffee
================================================
angular.module("templates-coffee", ["../test/fixtures/one.tpl.html", "../test/fixtures/two.tpl.html"])
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", ($templateCache) ->
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3")
])
angular.module("../test/fixtures/two.tpl.html", []).run(["$templateCache", ($templateCache) ->
$templateCache.put("../test/fixtures/two.tpl.html",
"Testing")
])
================================================
FILE: test/expected/compact_format_custom_options.js
================================================
angular.module("my-custom-template-module", ["fixtures/one.tpl.html", "fixtures/two.tpl.html"]);
angular.module("fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("fixtures/one.tpl.html",
"1 2 3");
}]);
angular.module("fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("fixtures/two.tpl.html",
"Testing");
}]);
================================================
FILE: test/expected/compact_format_default_options.js
================================================
angular.module("templates-compact_format_default_options", ["../test/fixtures/one.tpl.html", "../test/fixtures/two.tpl.html"]);
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
}]);
angular.module("../test/fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/two.tpl.html",
"Testing");
}]);
================================================
FILE: test/expected/custom_attribute_collapsed.js
================================================
angular.module("templates-custom_attribute_collapsed", ["../test/fixtures/custom_attribute_collapse.tpl.html"]);
angular.module("../test/fixtures/custom_attribute_collapse.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/custom_attribute_collapse.tpl.html",
"<div my-style=\"background-color: red;font-size: large;\"></div>\n" +
"");
}]);
================================================
FILE: test/expected/custom_attribute_not_collapsed.js
================================================
angular.module("templates-custom_attribute_not_collapsed", ["../test/fixtures/custom_attribute_collapse.tpl.html"]);
angular.module("../test/fixtures/custom_attribute_collapse.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/custom_attribute_collapse.tpl.html",
"<div\n" +
" my-style=\"\n" +
" background-color: red;\n" +
" font-size: large;\"\n" +
"></div>\n" +
"");
}]);
================================================
FILE: test/expected/double_quotes.js
================================================
angular.module("templates-double_quotes", ["../test/fixtures/four.tpl.html"]);
angular.module("../test/fixtures/four.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/four.tpl.html",
"This data is \"in quotes\"\n" +
"And this data is 'in single quotes'\n" +
"");
}]);
================================================
FILE: test/expected/empty_attribute.js
================================================
angular.module("templates-empty_attribute", ["../test/fixtures/empty_attribute.tpl.html"]);
angular.module("../test/fixtures/empty_attribute.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/empty_attribute.tpl.html",
"<div ui-view></div>\n" +
"");
}]);
================================================
FILE: test/expected/existing_module.js
================================================
angular.module("templates-existing_module").run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/expected/file_footer.js
================================================
angular.module("templates-file_footer", ["../test/fixtures/three.tpl.html"]);
angular.module("../test/fixtures/three.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
/* Module End */
================================================
FILE: test/expected/file_header.js
================================================
/* Module Start */
angular.module("templates-file_header", ["../test/fixtures/three.tpl.html"]);
angular.module("../test/fixtures/three.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/expected/file_header_footer.js
================================================
/* Module Start */
angular.module("templates-file_header_footer", ["../test/fixtures/three.tpl.html"]);
angular.module("../test/fixtures/three.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
/* Module End */
================================================
FILE: test/expected/files_array_custom_options_1.js
================================================
angular.module("my-custom-templates", ["fixtures/one.tpl.html"]);
angular.module("fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("fixtures/one.tpl.html",
"1 2 3");
}]);
================================================
FILE: test/expected/files_array_custom_options_2.js
================================================
angular.module("my-custom-templates", ["fixtures/two.tpl.html"]);
angular.module("fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("fixtures/two.tpl.html",
"Testing");
}]);
================================================
FILE: test/expected/files_array_default_options_1.js
================================================
angular.module("templates-files_array_default_options", ["../test/fixtures/one.tpl.html"]);
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
}]);
================================================
FILE: test/expected/files_array_default_options_2.js
================================================
angular.module("templates-files_array_default_options", ["../test/fixtures/two.tpl.html"]);
angular.module("../test/fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/two.tpl.html",
"Testing");
}]);
================================================
FILE: test/expected/files_object_custom_options_1.js
================================================
angular.module("my-custom-template-module", ["fixtures/one.tpl.html"]);
angular.module("fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("fixtures/one.tpl.html",
"1 2 3");
}]);
================================================
FILE: test/expected/files_object_custom_options_2.js
================================================
angular.module("my-custom-template-module", ["fixtures/two.tpl.html"]);
angular.module("fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("fixtures/two.tpl.html",
"Testing");
}]);
================================================
FILE: test/expected/files_object_default_options_1.js
================================================
angular.module("templates-files_object_default_options", ["../test/fixtures/one.tpl.html"]);
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
}]);
================================================
FILE: test/expected/files_object_default_options_2.js
================================================
angular.module("templates-files_object_default_options", ["../test/fixtures/two.tpl.html"]);
angular.module("../test/fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/two.tpl.html",
"Testing");
}]);
================================================
FILE: test/expected/htmlmin.js
================================================
angular.module("templates-htmlmin", ["../test/fixtures/five.tpl.html"]);
angular.module("../test/fixtures/five.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/five.tpl.html",
"<div class=\"quotes should be escaped\"><span><span><span>Lorem ipsum</span></span></span></div>");
}]);
================================================
FILE: test/expected/issue_26_withCollapseWhitespaceFalseDefaultQuotes.js
================================================
angular.module("templates-issue_26_withCollapseWhitespaceFalseDefaultQuotes", ["../test/fixtures/issue_26.tpl.html"]);
angular.module("../test/fixtures/issue_26.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/issue_26.tpl.html",
"<div>\n" +
" <div ng-class='\"bsp-alert-\" + (type || \"warning\")'></div>\n" +
"</div>\n" +
"");
}]);
================================================
FILE: test/expected/issue_26_withCollapseWhitespaceFalseDoubleQuotes.js
================================================
angular.module("templates-issue_26_withCollapseWhitespaceFalseDoubleQuotes", ["../test/fixtures/issue_26.tpl.html"]);
angular.module("../test/fixtures/issue_26.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/issue_26.tpl.html",
"<div>\n" +
" <div ng-class='\"bsp-alert-\" + (type || \"warning\")'></div>\n" +
"</div>\n" +
"");
}]);
================================================
FILE: test/expected/issue_26_withCollapseWhitespaceFalseSingleQuotes.js
================================================
angular.module('templates-issue_26_withCollapseWhitespaceFalseSingleQuotes', ['../test/fixtures/issue_26.tpl.html']);
angular.module('../test/fixtures/issue_26.tpl.html', []).run(['$templateCache', function($templateCache) {
$templateCache.put('../test/fixtures/issue_26.tpl.html',
'<div>\n' +
' <div ng-class=\'"bsp-alert-" + (type || "warning")\'></div>\n' +
'</div>\n' +
'');
}]);
================================================
FILE: test/expected/issue_26_withCollapseWhitespaceTrueDefaultQuotes.js
================================================
angular.module("templates-issue_26_withCollapseWhitespaceTrueDefaultQuotes", ["../test/fixtures/issue_26.tpl.html"]);
angular.module("../test/fixtures/issue_26.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/issue_26.tpl.html",
"<div>\n" +
" <div ng-class='\"bsp-alert-\" + (type || \"warning\")'></div>\n" +
"</div>\n" +
"");
}]);
================================================
FILE: test/expected/issue_26_withCollapseWhitespaceTrueDoubleQuotes.js
================================================
angular.module("templates-issue_26_withCollapseWhitespaceTrueDoubleQuotes", ["../test/fixtures/issue_26.tpl.html"]);
angular.module("../test/fixtures/issue_26.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/issue_26.tpl.html",
"<div>\n" +
" <div ng-class='\"bsp-alert-\" + (type || \"warning\")'></div>\n" +
"</div>\n" +
"");
}]);
================================================
FILE: test/expected/issue_26_withCollapseWhitespaceTrueSingleQuotes.js
================================================
angular.module('templates-issue_26_withCollapseWhitespaceTrueSingleQuotes', ['../test/fixtures/issue_26.tpl.html']);
angular.module('../test/fixtures/issue_26.tpl.html', []).run(['$templateCache', function($templateCache) {
$templateCache.put('../test/fixtures/issue_26.tpl.html',
'<div>\n' +
' <div ng-class=\'"bsp-alert-" + (type || "warning")\'></div>\n' +
'</div>\n' +
'');
}]);
================================================
FILE: test/expected/issue_26_withoutCollapseWhitespaceDefaultQuotes.js
================================================
angular.module("templates-issue_26_withoutCollapseWhitespaceDefaultQuotes", ["../test/fixtures/issue_26.tpl.html"]);
angular.module("../test/fixtures/issue_26.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/issue_26.tpl.html",
"<div>\n" +
" <div ng-class='\"bsp-alert-\" + (type || \"warning\")'></div>\n" +
"</div>\n" +
"");
}]);
================================================
FILE: test/expected/issue_26_withoutCollapseWhitespaceDoubleQuotes.js
================================================
angular.module("templates-issue_26_withoutCollapseWhitespaceDoubleQuotes", ["../test/fixtures/issue_26.tpl.html"]);
angular.module("../test/fixtures/issue_26.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/issue_26.tpl.html",
"<div>\n" +
" <div ng-class='\"bsp-alert-\" + (type || \"warning\")'></div>\n" +
"</div>\n" +
"");
}]);
================================================
FILE: test/expected/issue_26_withoutCollapseWhitespaceSingleQuotes.js
================================================
angular.module('templates-issue_26_withoutCollapseWhitespaceSingleQuotes', ['../test/fixtures/issue_26.tpl.html']);
angular.module('../test/fixtures/issue_26.tpl.html', []).run(['$templateCache', function($templateCache) {
$templateCache.put('../test/fixtures/issue_26.tpl.html',
'<div>\n' +
' <div ng-class=\'"bsp-alert-" + (type || "warning")\'></div>\n' +
'</div>\n' +
'');
}]);
================================================
FILE: test/expected/module_as_function.js
================================================
angular.module("NAME_FROM_FUNCTION", ["../test/fixtures/one.tpl.html", "../test/fixtures/two.tpl.html"]);
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
}]);
angular.module("../test/fixtures/two.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/two.tpl.html",
"Testing");
}]);
================================================
FILE: test/expected/multi_lines.js
================================================
angular.module("templates-multi_lines", ["../test/fixtures/three.tpl.html"]);
angular.module("../test/fixtures/three.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/expected/multi_lines_4spaces.js
================================================
angular.module("templates-multi_lines_4space", ["../test/fixtures/three.tpl.html"]);
angular.module("../test/fixtures/three.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/expected/multi_lines_tabs.js
================================================
angular.module("templates-multi_lines_tabs", ["../test/fixtures/three.tpl.html"]);
angular.module("../test/fixtures/three.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/expected/process_all_pug.js
================================================
angular.module("templates-process_all_pug", ["../test/fixtures/process_pug_custom.pug", "../test/fixtures/process_pug_with_include.pug", "../test/fixtures/process_pug.pug", "../test/fixtures/pug_include.pug"]);
angular.module("../test/fixtures/process_pug_custom.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug_custom.pug",
"<a href=\"href\">Great</a>");
}]);
angular.module("../test/fixtures/process_pug_with_include.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug_with_include.pug",
"<h1>I'm an include!</h1>");
}]);
angular.module("../test/fixtures/process_pug.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug.pug",
"<p class=\"example\">Hello World!</p><div id=\"greeting\">Nice</div><div id=\"watch\">test</div>");
}]);
angular.module("../test/fixtures/pug_include.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/pug_include.pug",
"<h1>I'm an include!</h1>");
}]);
================================================
FILE: test/expected/process_all_pug_after_change.js
================================================
angular.module("templates-process_all_pug", ["../test/fixtures/process_pug_custom.pug", "../test/fixtures/process_pug_with_include.pug", "../test/fixtures/process_pug.pug", "../test/fixtures/pug_include.pug"]);
angular.module("../test/fixtures/process_pug_custom.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug_custom.pug",
"<a href=\"href\">Great</a>");
}]);
angular.module("../test/fixtures/process_pug_with_include.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug_with_include.pug",
"<h1>I'm an include!</h1>");
}]);
angular.module("../test/fixtures/process_pug.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug.pug",
"<p class=\"example\">Hello World!</p><div id=\"greeting\">Nice</div><div id=\"watch\">test</div>");
}]);
angular.module("../test/fixtures/pug_include.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/pug_include.pug",
"<h1>I'm an include!</h1>");
}]);
================================================
FILE: test/expected/process_function.js
================================================
angular.module("templates-process_function", ["../test/fixtures/process_function.tpl.html"]);
angular.module("../test/fixtures/process_function.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_function.tpl.html",
"<h1> 1 </h1>\n" +
"<h2> 2 </h2>\n" +
"<h3> 3 </h3>\n" +
"");
}]);
================================================
FILE: test/expected/process_pug.js
================================================
angular.module("templates-process_pug", ["../test/fixtures/process_pug.pug"]);
angular.module("../test/fixtures/process_pug.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug.pug",
"<p class=\"example\">Hello World!</p>\n" +
"<div id=\"greeting\">Nice</div>");
}]);
================================================
FILE: test/expected/process_pug_custom.js
================================================
angular.module("templates-process_pug_custom", ["../test/fixtures/process_pug_custom.pug"]);
angular.module("../test/fixtures/process_pug_custom.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug_custom.pug",
"<a href>Great</a>");
}]);
================================================
FILE: test/expected/process_pug_with_include.js
================================================
angular.module("templates-process_pug_with_include", ["../test/fixtures/process_pug_with_include.pug"]);
angular.module("../test/fixtures/process_pug_with_include.pug", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_pug_with_include.pug",
"<h1>I'm an include!</h1>");
}]);
================================================
FILE: test/expected/process_template.js
================================================
angular.module("templates-process_template", ["../test/fixtures/process_template.tpl.html"]);
angular.module("../test/fixtures/process_template.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/process_template.tpl.html",
"<h1> Main Title </h1>\n" +
"<h2> Subtitle with {{ interpolation }} </h2>\n" +
"");
}]);
================================================
FILE: test/expected/regex_in_template.js
================================================
angular.module("templates-regex_in_template", ["../test/fixtures/pattern.tpl.html"]);
angular.module("../test/fixtures/pattern.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/pattern.tpl.html",
"<form>\n" +
"<span class=\"registration-error\" ng-show=\"regForm.password.$error.pattern\">- Fail to match..</span>\n" +
"<input type=\"password\" ng-model=\"registerForm.password\" name=\"password\" ng-pattern=\"/^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\\d\\W]).*$/\" required/>\n" +
"</form>\n" +
"");
}]);
================================================
FILE: test/expected/rename.js
================================================
angular.module("templates-rename", ["../test/fixtures/one.tpl", "../test/fixtures/two.tpl"]);
angular.module("../test/fixtures/one.tpl", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl",
"1 2 3");
}]);
angular.module("../test/fixtures/two.tpl", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/two.tpl",
"Testing");
}]);
================================================
FILE: test/expected/single_module.coffee
================================================
angular.module("templates-single_module_coffee", []).run(["$templateCache", ($templateCache) ->
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3")
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"")
])
================================================
FILE: test/expected/single_module.js
================================================
angular.module("templates-single_module", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/expected/single_module_strict.js
================================================
angular.module("templates-single_module_strict", []).run(["$templateCache", function($templateCache) {
"use strict";
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
$templateCache.put("../test/fixtures/three.tpl.html",
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/expected/single_quotes.js
================================================
angular.module('templates-single_quotes', ['../test/fixtures/four.tpl.html']);
angular.module('../test/fixtures/four.tpl.html', []).run(['$templateCache', function($templateCache) {
$templateCache.put('../test/fixtures/four.tpl.html',
'This data is "in quotes"\n' +
'And this data is \'in single quotes\'\n' +
'');
}]);
================================================
FILE: test/expected/strict_mode.js
================================================
angular.module("templates-strict_mode", ["../test/fixtures/one.tpl.html"]);
angular.module("../test/fixtures/one.tpl.html", []).run(["$templateCache", function($templateCache) {
"use strict";
$templateCache.put("../test/fixtures/one.tpl.html",
"1 2 3");
}]);
================================================
FILE: test/expected/template_path_in_comment.js
================================================
angular.module("templates-template_path_in_comment", ["../test/fixtures/three.tpl.html"]);
angular.module("../test/fixtures/three.tpl.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("../test/fixtures/three.tpl.html",
"<!-- template: test/fixtures/three.tpl.html -->\n" +
"Multiple\n" +
"Lines\n" +
"");
}]);
================================================
FILE: test/fixtures/broken_newlines.tpl.html
================================================
abc
def
================================================
FILE: test/fixtures/custom_attribute_collapse.tpl.html
================================================
<div
my-style="
background-color: red;
font-size: large;"
></div>
================================================
FILE: test/fixtures/empty_attribute.tpl.html
================================================
<div ui-view></div>
================================================
FILE: test/fixtures/five.tpl.html
================================================
<div class="quotes should be escaped">
<span>
<span>
<span>
Lorem ipsum
</span>
</span>
</span>
</div>
================================================
FILE: test/fixtures/four.tpl.html
================================================
This data is "in quotes"
And this data is 'in single quotes'
================================================
FILE: test/fixtures/issue_26.tpl.html
================================================
<div>
<div ng-class='"bsp-alert-" + (type || "warning")'></div>
</div>
================================================
FILE: test/fixtures/one.tpl.html
================================================
1 2 3
================================================
FILE: test/fixtures/pattern.tpl.html
================================================
<form>
<span class="registration-error" ng-show="regForm.password.$error.pattern">- Fail to match..</span>
<input type="password" ng-model="registerForm.password" name="password" ng-pattern="/^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\d\W]).*$/" required/>
</form>
================================================
FILE: test/fixtures/process_function.tpl.html
================================================
<h1> (ONE) </h1>
<h2> (TWO) </h2>
<h3> (THREE) </h3>
================================================
FILE: test/fixtures/process_pug.pug
================================================
p.example Hello World!
#greeting Nice
================================================
FILE: test/fixtures/process_pug_custom.pug
================================================
a(href) Great
================================================
FILE: test/fixtures/process_pug_with_include.pug
================================================
include ./pug_include
================================================
FILE: test/fixtures/process_template.tpl.html
================================================
<h1> <%= html2js.process_template.testMessages.title %> </h1>
<h2> <%= html2js.process_template.testMessages.subtitle %> </h2>
================================================
FILE: test/fixtures/pug_include.pug
================================================
h1 I'm an include!
================================================
FILE: test/fixtures/three.tpl.html
================================================
Multiple
Lines
================================================
FILE: test/fixtures/two.tpl.html
================================================
Testing
================================================
FILE: test/html2js_test.js
================================================
'use strict';
var grunt = require('grunt');
/*
======== A Handy Little Nodeunit Reference ========
https://github.com/caolan/nodeunit
Test methods:
test.expect(numAssertions)
test.done()
Test assertions:
test.ok(value, [message])
test.equal(actual, expected, [message])
test.notEqual(actual, expected, [message])
test.deepEqual(actual, expected, [message])
test.notDeepEqual(actual, expected, [message])
test.strictEqual(actual, expected, [message])
test.notStrictEqual(actual, expected, [message])
test.throws(block, [error], [message])
test.doesNotThrow(block, [error], [message])
test.ifError(value)
*/
var strContext = function (s, pos, size) {
var start = pos - size > 0 ? pos - size : 0;
var end = pos + size < s.length ? pos + size : pos.length;
return s.substring(start, end);
};
var assertFileContentsEqual = function (test, actualFile, expectedFile, message) {
var actual = grunt.file.read(actualFile);
var expected = grunt.util.normalizelf(grunt.file.read(expectedFile));
var i, pos = null;
for (i = 0; i < expected.length - 1; i++) {
if (actual.charAt(i) !== expected.charAt(i)) {
pos = i;
break;
}
}
if (pos !== null) {
message += ' at character ' + i + ': ' + strContext(actual, pos, 5);
}
test.equal(actual, expected, message);
};
var assertFileDoesNotExist = function (test, unexpectedFile, message) {
test.equal(false, grunt.file.exists(unexpectedFile), message);
};
exports.html2js = {
setUp: function (done) {
// setup here if necessary
done();
},
amd_module: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/amd_module.js',
'test/expected/amd_module.js',
'expected use of amd module');
test.done();
},
amd_module_custom_prefix: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/amd_module_custom_prefix.js',
'test/expected/amd_module_custom_prefix.js',
'expected use of amd module with custom prefix');
test.done();
},
amd_module_custom_suffix: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/amd_module_custom_suffix.js',
'test/expected/amd_module_custom_suffix.js',
'expected use of amd module with custom suffix');
test.done();
},
broken_newlines: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/broken_newlines.js',
'test/expected/broken_newlines.js',
'expected correct newlines');
test.done();
},
coffee: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/coffee.coffee',
'test/expected/coffee.coffee',
'expected compiled template module');
test.done();
},
compact_format_custom_options: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/compact_format_custom_options.js',
'test/expected/compact_format_custom_options.js',
'expected compiled template module');
test.done();
},
compact_format_default_options: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/compact_format_default_options.js',
'test/expected/compact_format_default_options.js',
'expected compiled template module');
test.done();
},
custom_attribute_collapsed: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/custom_attribute_collapsed.js',
'test/expected/custom_attribute_collapsed.js',
'expected compiled template module');
test.done();
},
custom_attribute_not_collapsed: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/custom_attribute_not_collapsed.js',
'test/expected/custom_attribute_not_collapsed.js',
'expected compiled template module');
test.done();
},
double_quotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/double_quotes.js',
'test/expected/double_quotes.js',
'expected compiled template module');
test.done();
},
empty_attribute: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/empty_attribute.js',
'test/expected/empty_attribute.js',
'expected compiled template module');
test.done();
},
empty_module: function (test) {
test.expect(1);
assertFileDoesNotExist(test, 'tmp/empty_module.js',
'test/expected/empty_module.js',
'expected empty module');
test.done();
},
existing_module: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/existing_module.js',
'test/expected/existing_module.js',
'expected use of existing module');
test.done();
},
file_footer: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/file_footer.js',
'test/expected/file_footer.js',
'expected compiled template module with footer');
test.done();
},
file_header: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/file_header.js',
'test/expected/file_header.js',
'expected compiled template module with header');
test.done();
},
file_header_footer: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/file_header_footer.js',
'test/expected/file_header_footer.js',
'expected compiled template module with header and footer');
test.done();
},
files_array_custom_options: function (test) {
test.expect(2);
assertFileContentsEqual(test, 'tmp/files_array_custom_options_1.js',
'test/expected/files_array_custom_options_1.js',
'expected compiled template module');
assertFileContentsEqual(test, 'tmp/files_array_custom_options_2.js',
'test/expected/files_array_custom_options_2.js',
'expected compiled template module');
test.done();
},
files_array_default_options: function (test) {
test.expect(2);
assertFileContentsEqual(test, 'tmp/files_array_default_options_1.js',
'test/expected/files_array_default_options_1.js',
'expected compiled template module');
assertFileContentsEqual(test, 'tmp/files_array_default_options_2.js',
'test/expected/files_array_default_options_2.js',
'expected compiled template module');
test.done();
},
files_object_custom_options: function (test) {
test.expect(2);
assertFileContentsEqual(test, 'tmp/files_object_custom_options_1.js',
'test/expected/files_object_custom_options_1.js',
'expected compiled template module');
assertFileContentsEqual(test, 'tmp/files_object_custom_options_2.js',
'test/expected/files_object_custom_options_2.js',
'expected compiled template module');
test.done();
},
files_object_default_options: function (test) {
test.expect(2);
assertFileContentsEqual(test, 'tmp/files_object_default_options_1.js',
'test/expected/files_object_default_options_1.js',
'expected compiled template module');
assertFileContentsEqual(test, 'tmp/files_object_default_options_2.js',
'test/expected/files_object_default_options_2.js',
'expected compiled template module');
test.done();
},
htmlmin: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/htmlmin.js',
'test/expected/htmlmin.js',
'expected minified template');
test.done();
},
issue_26_withCollapseWhitespaceFalseDefaultQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withCollapseWhitespaceFalseDefaultQuotes.js',
'test/expected/issue_26_withCollapseWhitespaceFalseDefaultQuotes.js',
'expected issue 26 with whitespace collapse false and default quotes'
);
test.done();
},
issue_26_withCollapseWhitespaceFalseDoubleQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withCollapseWhitespaceFalseDoubleQuotes.js',
'test/expected/issue_26_withCollapseWhitespaceFalseDoubleQuotes.js',
'expected issue 26 with whitespace collapse false and Double quotes'
);
test.done();
},
issue_26_withCollapseWhitespaceFalseSingleQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withCollapseWhitespaceFalseSingleQuotes.js',
'test/expected/issue_26_withCollapseWhitespaceFalseSingleQuotes.js',
'expected issue 26 with whitespace collapse false and Single quotes'
);
test.done();
},
issue_26_withCollapseWhitespaceTrueDefaultQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withCollapseWhitespaceTrueDefaultQuotes.js',
'test/expected/issue_26_withCollapseWhitespaceTrueDefaultQuotes.js',
'expected issue 26 with whitespace collapse true and default quotes'
);
test.done();
},
issue_26_withCollapseWhitespaceTrueDoubleQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withCollapseWhitespaceTrueDoubleQuotes.js',
'test/expected/issue_26_withCollapseWhitespaceTrueDoubleQuotes.js',
'expected issue 26 with whitespace collapse true and Double quotes'
);
test.done();
},
issue_26_withCollapseWhitespaceTrueSingleQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withCollapseWhitespaceTrueSingleQuotes.js',
'test/expected/issue_26_withCollapseWhitespaceTrueSingleQuotes.js',
'expected issue 26 with whitespace collapse true and Single quotes'
);
test.done();
},
issue_26_withoutCollapseWhitespaceDefaultQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withoutCollapseWhitespaceDefaultQuotes.js',
'test/expected/issue_26_withoutCollapseWhitespaceDefaultQuotes.js',
'expected issue 26 without whitespace collapse and default quotes'
);
test.done();
},
issue_26_withoutCollapseWhitespaceDoubleQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withoutCollapseWhitespaceDoubleQuotes.js',
'test/expected/issue_26_withoutCollapseWhitespaceDoubleQuotes.js',
'expected issue 26 without whitespace collapse and Double quotes'
);
test.done();
},
issue_26_withoutCollapseWhitespaceSingleQuotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/issue_26_withoutCollapseWhitespaceSingleQuotes.js',
'test/expected/issue_26_withoutCollapseWhitespaceSingleQuotes.js',
'expected issue 26 without whitespace collapse and Single quotes'
);
test.done();
},
issue_76_missingSourceFile: function(test){
// @todo Not exactly sure what should go in here!
test.expect(0);
test.done();
},
issue_76_missingSourceFiles: function(test){
// @todo Not exactly sure what should go in here!
test.expect(0);
test.done();
},
issue_76_missingSourceFilesFirst: function(test){
// @todo Not exactly sure what should go in here!
test.expect(0);
test.done();
},
issue_76_missingSourceFilesLast: function(test){
// @todo Not exactly sure what should go in here!
test.expect(0);
test.done();
},
issue_76_missingSourceFilesMiddle: function(test){
// @todo Not exactly sure what should go in here!
test.expect(0);
test.done();
},
module_as_function: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/module_as_function.js',
'test/expected/module_as_function.js',
'expected compiled template module');
test.done();
},
multi_lines: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/multi_lines.js',
'test/expected/multi_lines.js',
'expected compiled template module');
test.done();
},
multi_lines_4spaces: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/multi_lines_4spaces.js',
'test/expected/multi_lines_4spaces.js',
'expected compiled template module');
test.done();
},
multi_lines_tabs: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/multi_lines_tabs.js',
'test/expected/multi_lines_tabs.js',
'expected compiled template module');
test.done();
},
process_all_pug: function (test) {
test.expect(1);
// This test is run with options.watch on
// We need to edit a fixture file to make sure it is watched and re-compiled
var file2Change = 'test/fixtures/process_pug.pug';
var contents = grunt.file.read(file2Change);
var newContents = contents + '\n#watch test';
// Write edited fixture file
grunt.file.write(file2Change, grunt.util.normalizelf(newContents));
// wait for the watch-change to process
setTimeout(function () {
// Check re-compiled with changes were added
assertFileContentsEqual(test, 'tmp/process_all_pug.js',
'test/expected/process_all_pug_after_change.js',
'expected pug template to be processed with custom options');
//reset fixture file to original contents
grunt.file.write(file2Change, grunt.util.normalizelf(contents));
test.done();
}, 1500);
},
process_function: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/process_function.js',
'test/expected/process_function.js',
'expected grunt templates to be processed by a custom function');
test.done();
},
process_pug: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/process_pug.js',
'test/expected/process_pug.js',
'expected pug template to be processed');
test.done();
},
process_pug_custom: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/process_pug_custom.js',
'test/expected/process_pug_custom.js',
'expected pug template to be processed with custom options');
test.done();
},
process_pug_with_include: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/process_pug_with_include.js',
'test/expected/process_pug_with_include.js',
'expected pug template to be processed with custom options');
test.done();
},
process_template: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/process_template.js',
'test/expected/process_template.js',
'expected grunt templates to be processed');
test.done();
},
regex_in_template: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/regex_in_template.js',
'test/expected/regex_in_template.js',
'expected compiled template module');
test.done();
},
rename: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/rename.js',
'test/expected/rename.js',
'expected compiled template module');
test.done();
},
single_module: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/single_module.js',
'test/expected/single_module.js',
'expected template with single module');
test.done();
},
single_module_coffee: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/single_module.coffee',
'test/expected/single_module.coffee',
'expected coffee template with single module');
test.done();
},
single_module_strict: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/single_module_strict.js',
'test/expected/single_module_strict.js',
'expected template with single strict module');
test.done();
},
single_quotes: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/single_quotes.js',
'test/expected/single_quotes.js',
'expected compiled template module');
test.done();
},
strict_mode: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/strict_mode.js',
'test/expected/strict_mode.js',
'expected strict mode in templates');
test.done();
},
template_path_in_comment: function (test) {
test.expect(1);
assertFileContentsEqual(test, 'tmp/template_path_in_comment.js',
'test/expected/template_path_in_comment.js',
'expected template path in comment');
test.done();
}
};
gitextract_mrc6b39g/
├── .gitattributes
├── .github/
│ └── workflows/
│ └── semgrep.yml
├── .gitignore
├── .jshintrc
├── .travis.yml
├── Gruntfile.js
├── LICENSE-MIT
├── README.md
├── package.json
├── tasks/
│ └── html2js.js
└── test/
├── expected/
│ ├── amd_module.js
│ ├── amd_module_custom_prefix.js
│ ├── amd_module_custom_suffix.js
│ ├── broken_newlines.js
│ ├── coffee.coffee
│ ├── compact_format_custom_options.js
│ ├── compact_format_default_options.js
│ ├── custom_attribute_collapsed.js
│ ├── custom_attribute_not_collapsed.js
│ ├── double_quotes.js
│ ├── empty_attribute.js
│ ├── existing_module.js
│ ├── file_footer.js
│ ├── file_header.js
│ ├── file_header_footer.js
│ ├── files_array_custom_options_1.js
│ ├── files_array_custom_options_2.js
│ ├── files_array_default_options_1.js
│ ├── files_array_default_options_2.js
│ ├── files_object_custom_options_1.js
│ ├── files_object_custom_options_2.js
│ ├── files_object_default_options_1.js
│ ├── files_object_default_options_2.js
│ ├── htmlmin.js
│ ├── issue_26_withCollapseWhitespaceFalseDefaultQuotes.js
│ ├── issue_26_withCollapseWhitespaceFalseDoubleQuotes.js
│ ├── issue_26_withCollapseWhitespaceFalseSingleQuotes.js
│ ├── issue_26_withCollapseWhitespaceTrueDefaultQuotes.js
│ ├── issue_26_withCollapseWhitespaceTrueDoubleQuotes.js
│ ├── issue_26_withCollapseWhitespaceTrueSingleQuotes.js
│ ├── issue_26_withoutCollapseWhitespaceDefaultQuotes.js
│ ├── issue_26_withoutCollapseWhitespaceDoubleQuotes.js
│ ├── issue_26_withoutCollapseWhitespaceSingleQuotes.js
│ ├── module_as_function.js
│ ├── multi_lines.js
│ ├── multi_lines_4spaces.js
│ ├── multi_lines_tabs.js
│ ├── process_all_pug.js
│ ├── process_all_pug_after_change.js
│ ├── process_function.js
│ ├── process_pug.js
│ ├── process_pug_custom.js
│ ├── process_pug_with_include.js
│ ├── process_template.js
│ ├── regex_in_template.js
│ ├── rename.js
│ ├── single_module.coffee
│ ├── single_module.js
│ ├── single_module_strict.js
│ ├── single_quotes.js
│ ├── strict_mode.js
│ └── template_path_in_comment.js
├── fixtures/
│ ├── broken_newlines.tpl.html
│ ├── custom_attribute_collapse.tpl.html
│ ├── empty_attribute.tpl.html
│ ├── five.tpl.html
│ ├── four.tpl.html
│ ├── issue_26.tpl.html
│ ├── one.tpl.html
│ ├── pattern.tpl.html
│ ├── process_function.tpl.html
│ ├── process_pug.pug
│ ├── process_pug_custom.pug
│ ├── process_pug_with_include.pug
│ ├── process_template.tpl.html
│ ├── pug_include.pug
│ ├── three.tpl.html
│ └── two.tpl.html
└── html2js_test.js
SYMBOL INDEX (2 symbols across 1 files)
FILE: tasks/html2js.js
function isPugTemplate (line 44) | function isPugTemplate (filepath) {
function generateModule (line 160) | function generateModule (f) {
Condensed preview — 79 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (86K chars).
[
{
"path": ".gitattributes",
"chars": 97,
"preview": "# this file has broken newlines, and we want it to stay this way\nbroken_newlines.tpl.html binary\n"
},
{
"path": ".github/workflows/semgrep.yml",
"chars": 403,
"preview": "on:\n pull_request: {}\n push:\n branches:\n - main\n - master\n paths:\n - .github/workflows/semgrep.yml\n sc"
},
{
"path": ".gitignore",
"chars": 40,
"preview": "node_modules\nnpm-debug.log\ntmp\ncoverage\n"
},
{
"path": ".jshintrc",
"chars": 206,
"preview": "{\n \"curly\": true,\n \"eqeqeq\": true,\n \"immed\": true,\n \"latedef\": true,\n \"newcap\": true,\n \"noarg\": true,\n \"sub\": tru"
},
{
"path": ".travis.yml",
"chars": 274,
"preview": "language: node_js\nsudo: false\nnode_js:\n - 10\n - 11\n - 12\n - 13\n - 14\n - 15\ninstall:\n - npm install\nbefore_script:"
},
{
"path": "Gruntfile.js",
"chars": 14447,
"preview": "/*\n * grunt-html2js\n * https://github.com/rquadling/grunt-html2js\n *\n * Copyright (c) 2013 Karl Goldstein\n * Copyright ("
},
{
"path": "LICENSE-MIT",
"chars": 1099,
"preview": "Copyright (c) 2013 Karl Goldstein\nCopyright (c) 2017-2021 Richard Quadling\n\nPermission is hereby granted, free of charge"
},
{
"path": "README.md",
"chars": 13502,
"preview": "[](https://travis-ci.org/rquadling/gru"
},
{
"path": "package.json",
"chars": 1228,
"preview": "{\n \"name\": \"grunt-html2js\",\n \"description\": \"Compiles AngularJS templates to JavaScript\",\n \"version\": \"0.9.0\",\n \"hom"
},
{
"path": "tasks/html2js.js",
"chars": 9127,
"preview": "/*\n * grunt-html2js\n * https://github.com/rquadling/grunt-html2js\n *\n * Copyright (c) 2013 Karl Goldstein\n * Copyright ("
},
{
"path": "test/expected/amd_module.js",
"chars": 503,
"preview": "define(['angular'], function(angular){angular.module('templates-amd_module', ['../test/fixtures/one.tpl.html', '../test/"
},
{
"path": "test/expected/amd_module_custom_prefix.js",
"chars": 512,
"preview": "define(['ng'], function(angular){angular.module(\"templates-amd_module_custom_prefix\", [\"../test/fixtures/one.tpl.html\", "
},
{
"path": "test/expected/amd_module_custom_suffix.js",
"chars": 527,
"preview": "define(['angular'], function(angular){angular.module(\"templates-amd_module_custom_suffix\", [\"../test/fixtures/one.tpl.ht"
},
{
"path": "test/expected/broken_newlines.js",
"chars": 304,
"preview": "angular.module(\"templates-broken_newlines\", [\"../test/fixtures/broken_newlines.tpl.html\"]);\n\nangular.module(\"../test/fix"
},
{
"path": "test/expected/coffee.coffee",
"chars": 437,
"preview": "angular.module(\"templates-coffee\", [\"../test/fixtures/one.tpl.html\", \"../test/fixtures/two.tpl.html\"])\n\nangular.module(\""
},
{
"path": "test/expected/compact_format_custom_options.js",
"chars": 419,
"preview": "angular.module(\"my-custom-template-module\", [\"fixtures/one.tpl.html\", \"fixtures/two.tpl.html\"]);\n\nangular.module(\"fixtur"
},
{
"path": "test/expected/compact_format_default_options.js",
"chars": 482,
"preview": "angular.module(\"templates-compact_format_default_options\", [\"../test/fixtures/one.tpl.html\", \"../test/fixtures/two.tpl.h"
},
{
"path": "test/expected/custom_attribute_collapsed.js",
"chars": 403,
"preview": "angular.module(\"templates-custom_attribute_collapsed\", [\"../test/fixtures/custom_attribute_collapse.tpl.html\"]);\n\nangula"
},
{
"path": "test/expected/custom_attribute_not_collapsed.js",
"chars": 482,
"preview": "angular.module(\"templates-custom_attribute_not_collapsed\", [\"../test/fixtures/custom_attribute_collapse.tpl.html\"]);\n\nan"
},
{
"path": "test/expected/double_quotes.js",
"chars": 335,
"preview": "angular.module(\"templates-double_quotes\", [\"../test/fixtures/four.tpl.html\"]);\n\nangular.module(\"../test/fixtures/four.tp"
},
{
"path": "test/expected/empty_attribute.js",
"chars": 317,
"preview": "angular.module(\"templates-empty_attribute\", [\"../test/fixtures/empty_attribute.tpl.html\"]);\n\nangular.module(\"../test/fix"
},
{
"path": "test/expected/existing_module.js",
"chars": 267,
"preview": "angular.module(\"templates-existing_module\").run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"../t"
},
{
"path": "test/expected/file_footer.js",
"chars": 306,
"preview": "angular.module(\"templates-file_footer\", [\"../test/fixtures/three.tpl.html\"]);\n\nangular.module(\"../test/fixtures/three.tp"
},
{
"path": "test/expected/file_header.js",
"chars": 308,
"preview": "/* Module Start */\n\nangular.module(\"templates-file_header\", [\"../test/fixtures/three.tpl.html\"]);\n\nangular.module(\"../te"
},
{
"path": "test/expected/file_header_footer.js",
"chars": 333,
"preview": "/* Module Start */\n\nangular.module(\"templates-file_header_footer\", [\"../test/fixtures/three.tpl.html\"]);\n\nangular.module"
},
{
"path": "test/expected/files_array_custom_options_1.js",
"chars": 226,
"preview": "angular.module(\"my-custom-templates\", [\"fixtures/one.tpl.html\"]);\n\nangular.module(\"fixtures/one.tpl.html\", []).run([\"$te"
},
{
"path": "test/expected/files_array_custom_options_2.js",
"chars": 228,
"preview": "angular.module(\"my-custom-templates\", [\"fixtures/two.tpl.html\"]);\n\nangular.module(\"fixtures/two.tpl.html\", []).run([\"$te"
},
{
"path": "test/expected/files_array_default_options_1.js",
"chars": 268,
"preview": "angular.module(\"templates-files_array_default_options\", [\"../test/fixtures/one.tpl.html\"]);\n\nangular.module(\"../test/fix"
},
{
"path": "test/expected/files_array_default_options_2.js",
"chars": 270,
"preview": "angular.module(\"templates-files_array_default_options\", [\"../test/fixtures/two.tpl.html\"]);\n\nangular.module(\"../test/fix"
},
{
"path": "test/expected/files_object_custom_options_1.js",
"chars": 232,
"preview": "angular.module(\"my-custom-template-module\", [\"fixtures/one.tpl.html\"]);\n\nangular.module(\"fixtures/one.tpl.html\", []).run"
},
{
"path": "test/expected/files_object_custom_options_2.js",
"chars": 234,
"preview": "angular.module(\"my-custom-template-module\", [\"fixtures/two.tpl.html\"]);\n\nangular.module(\"fixtures/two.tpl.html\", []).run"
},
{
"path": "test/expected/files_object_default_options_1.js",
"chars": 269,
"preview": "angular.module(\"templates-files_object_default_options\", [\"../test/fixtures/one.tpl.html\"]);\n\nangular.module(\"../test/fi"
},
{
"path": "test/expected/files_object_default_options_2.js",
"chars": 271,
"preview": "angular.module(\"templates-files_object_default_options\", [\"../test/fixtures/two.tpl.html\"]);\n\nangular.module(\"../test/fi"
},
{
"path": "test/expected/htmlmin.js",
"chars": 342,
"preview": "angular.module(\"templates-htmlmin\", [\"../test/fixtures/five.tpl.html\"]);\n\nangular.module(\"../test/fixtures/five.tpl.html"
},
{
"path": "test/expected/issue_26_withCollapseWhitespaceFalseDefaultQuotes.js",
"chars": 409,
"preview": "angular.module(\"templates-issue_26_withCollapseWhitespaceFalseDefaultQuotes\", [\"../test/fixtures/issue_26.tpl.html\"]);\n\n"
},
{
"path": "test/expected/issue_26_withCollapseWhitespaceFalseDoubleQuotes.js",
"chars": 408,
"preview": "angular.module(\"templates-issue_26_withCollapseWhitespaceFalseDoubleQuotes\", [\"../test/fixtures/issue_26.tpl.html\"]);\n\na"
},
{
"path": "test/expected/issue_26_withCollapseWhitespaceFalseSingleQuotes.js",
"chars": 406,
"preview": "angular.module('templates-issue_26_withCollapseWhitespaceFalseSingleQuotes', ['../test/fixtures/issue_26.tpl.html']);\n\na"
},
{
"path": "test/expected/issue_26_withCollapseWhitespaceTrueDefaultQuotes.js",
"chars": 408,
"preview": "angular.module(\"templates-issue_26_withCollapseWhitespaceTrueDefaultQuotes\", [\"../test/fixtures/issue_26.tpl.html\"]);\n\na"
},
{
"path": "test/expected/issue_26_withCollapseWhitespaceTrueDoubleQuotes.js",
"chars": 407,
"preview": "angular.module(\"templates-issue_26_withCollapseWhitespaceTrueDoubleQuotes\", [\"../test/fixtures/issue_26.tpl.html\"]);\n\nan"
},
{
"path": "test/expected/issue_26_withCollapseWhitespaceTrueSingleQuotes.js",
"chars": 405,
"preview": "angular.module('templates-issue_26_withCollapseWhitespaceTrueSingleQuotes', ['../test/fixtures/issue_26.tpl.html']);\n\nan"
},
{
"path": "test/expected/issue_26_withoutCollapseWhitespaceDefaultQuotes.js",
"chars": 407,
"preview": "angular.module(\"templates-issue_26_withoutCollapseWhitespaceDefaultQuotes\", [\"../test/fixtures/issue_26.tpl.html\"]);\n\nan"
},
{
"path": "test/expected/issue_26_withoutCollapseWhitespaceDoubleQuotes.js",
"chars": 406,
"preview": "angular.module(\"templates-issue_26_withoutCollapseWhitespaceDoubleQuotes\", [\"../test/fixtures/issue_26.tpl.html\"]);\n\nang"
},
{
"path": "test/expected/issue_26_withoutCollapseWhitespaceSingleQuotes.js",
"chars": 404,
"preview": "angular.module('templates-issue_26_withoutCollapseWhitespaceSingleQuotes', ['../test/fixtures/issue_26.tpl.html']);\n\nang"
},
{
"path": "test/expected/module_as_function.js",
"chars": 460,
"preview": "angular.module(\"NAME_FROM_FUNCTION\", [\"../test/fixtures/one.tpl.html\", \"../test/fixtures/two.tpl.html\"]);\n\nangular.modul"
},
{
"path": "test/expected/multi_lines.js",
"chars": 288,
"preview": "angular.module(\"templates-multi_lines\", [\"../test/fixtures/three.tpl.html\"]);\n\nangular.module(\"../test/fixtures/three.tp"
},
{
"path": "test/expected/multi_lines_4spaces.js",
"chars": 309,
"preview": "angular.module(\"templates-multi_lines_4space\", [\"../test/fixtures/three.tpl.html\"]);\n\nangular.module(\"../test/fixtures/t"
},
{
"path": "test/expected/multi_lines_tabs.js",
"chars": 286,
"preview": "angular.module(\"templates-multi_lines_tabs\", [\"../test/fixtures/three.tpl.html\"]);\n\nangular.module(\"../test/fixtures/thr"
},
{
"path": "test/expected/process_all_pug.js",
"chars": 1129,
"preview": "angular.module(\"templates-process_all_pug\", [\"../test/fixtures/process_pug_custom.pug\", \"../test/fixtures/process_pug_wi"
},
{
"path": "test/expected/process_all_pug_after_change.js",
"chars": 1129,
"preview": "angular.module(\"templates-process_all_pug\", [\"../test/fixtures/process_pug_custom.pug\", \"../test/fixtures/process_pug_wi"
},
{
"path": "test/expected/process_function.js",
"chars": 360,
"preview": "angular.module(\"templates-process_function\", [\"../test/fixtures/process_function.tpl.html\"]);\n\nangular.module(\"../test/f"
},
{
"path": "test/expected/process_pug.js",
"chars": 335,
"preview": "angular.module(\"templates-process_pug\", [\"../test/fixtures/process_pug.pug\"]);\n\nangular.module(\"../test/fixtures/process"
},
{
"path": "test/expected/process_pug_custom.js",
"chars": 301,
"preview": "angular.module(\"templates-process_pug_custom\", [\"../test/fixtures/process_pug_custom.pug\"]);\n\nangular.module(\"../test/fi"
},
{
"path": "test/expected/process_pug_with_include.js",
"chars": 332,
"preview": "angular.module(\"templates-process_pug_with_include\", [\"../test/fixtures/process_pug_with_include.pug\"]);\n\nangular.module"
},
{
"path": "test/expected/process_template.js",
"chars": 378,
"preview": "angular.module(\"templates-process_template\", [\"../test/fixtures/process_template.tpl.html\"]);\n\nangular.module(\"../test/f"
},
{
"path": "test/expected/regex_in_template.js",
"chars": 583,
"preview": "angular.module(\"templates-regex_in_template\", [\"../test/fixtures/pattern.tpl.html\"]);\n\nangular.module(\"../test/fixtures/"
},
{
"path": "test/expected/rename.js",
"chars": 428,
"preview": "angular.module(\"templates-rename\", [\"../test/fixtures/one.tpl\", \"../test/fixtures/two.tpl\"]);\n\nangular.module(\"../test/f"
},
{
"path": "test/expected/single_module.coffee",
"chars": 265,
"preview": "angular.module(\"templates-single_module_coffee\", []).run([\"$templateCache\", ($templateCache) ->\n $templateCache.put(\".."
},
{
"path": "test/expected/single_module.js",
"chars": 269,
"preview": "angular.module(\"templates-single_module\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\".."
},
{
"path": "test/expected/single_module_strict.js",
"chars": 292,
"preview": "angular.module(\"templates-single_module_strict\", []).run([\"$templateCache\", function($templateCache) {\n \"use strict\";\n "
},
{
"path": "test/expected/single_quotes.js",
"chars": 335,
"preview": "angular.module('templates-single_quotes', ['../test/fixtures/four.tpl.html']);\n\nangular.module('../test/fixtures/four.tp"
},
{
"path": "test/expected/strict_mode.js",
"chars": 268,
"preview": "angular.module(\"templates-strict_mode\", [\"../test/fixtures/one.tpl.html\"]);\n\nangular.module(\"../test/fixtures/one.tpl.ht"
},
{
"path": "test/expected/template_path_in_comment.js",
"chars": 359,
"preview": "angular.module(\"templates-template_path_in_comment\", [\"../test/fixtures/three.tpl.html\"]);\n\nangular.module(\"../test/fixt"
},
{
"path": "test/fixtures/broken_newlines.tpl.html",
"chars": 9,
"preview": "abc\r\r\ndef"
},
{
"path": "test/fixtures/custom_attribute_collapse.tpl.html",
"chars": 98,
"preview": "<div\n my-style=\"\n background-color: red;\n font-size: large;\"\n></div>\n"
},
{
"path": "test/fixtures/empty_attribute.tpl.html",
"chars": 20,
"preview": "<div ui-view></div>\n"
},
{
"path": "test/fixtures/five.tpl.html",
"chars": 135,
"preview": "<div class=\"quotes should be escaped\">\n <span>\n <span>\n <span>\n Lorem ipsum\n </span>\n </span>\n "
},
{
"path": "test/fixtures/four.tpl.html",
"chars": 61,
"preview": "This data is \"in quotes\"\nAnd this data is 'in single quotes'\n"
},
{
"path": "test/fixtures/issue_26.tpl.html",
"chars": 75,
"preview": "<div>\n <div ng-class='\"bsp-alert-\" + (type || \"warning\")'></div>\n</div>\n"
},
{
"path": "test/fixtures/one.tpl.html",
"chars": 5,
"preview": "1 2 3"
},
{
"path": "test/fixtures/pattern.tpl.html",
"chars": 264,
"preview": "<form>\n<span class=\"registration-error\" ng-show=\"regForm.password.$error.pattern\">- Fail to match..</span>\n<input type=\""
},
{
"path": "test/fixtures/process_function.tpl.html",
"chars": 53,
"preview": "<h1> (ONE) </h1>\n<h2> (TWO) </h2>\n<h3> (THREE) </h3>\n"
},
{
"path": "test/fixtures/process_pug.pug",
"chars": 38,
"preview": "p.example Hello World!\n#greeting Nice\n"
},
{
"path": "test/fixtures/process_pug_custom.pug",
"chars": 14,
"preview": "a(href) Great\n"
},
{
"path": "test/fixtures/process_pug_with_include.pug",
"chars": 22,
"preview": "include ./pug_include\n"
},
{
"path": "test/fixtures/process_template.tpl.html",
"chars": 127,
"preview": "<h1> <%= html2js.process_template.testMessages.title %> </h1>\n<h2> <%= html2js.process_template.testMessages.subtitle %>"
},
{
"path": "test/fixtures/pug_include.pug",
"chars": 19,
"preview": "h1 I'm an include!\n"
},
{
"path": "test/fixtures/three.tpl.html",
"chars": 15,
"preview": "Multiple\nLines\n"
},
{
"path": "test/fixtures/two.tpl.html",
"chars": 7,
"preview": "Testing"
},
{
"path": "test/html2js_test.js",
"chars": 16264,
"preview": "'use strict';\n\nvar grunt = require('grunt');\n\n/*\n ======== A Handy Little Nodeunit Reference ========\n https://github.co"
}
]
About this extraction
This page contains the full source code of the karlgoldstein/grunt-html2js GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 79 files (75.9 KB), approximately 21.4k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.