{"id":15767871,"url":"https://github.com/bubkoo/grunt-underscore-compiler","last_synced_at":"2025-07-21T04:08:15.119Z","repository":{"id":23604964,"uuid":"26973902","full_name":"bubkoo/grunt-underscore-compiler","owner":"bubkoo","description":"Compile underscore templates into JavaScript files.","archived":false,"fork":false,"pushed_at":"2016-04-27T03:16:28.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T12:50:31.309Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bubkoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-21T19:08:41.000Z","updated_at":"2016-05-19T15:26:44.000Z","dependencies_parsed_at":"2022-08-21T19:40:15.404Z","dependency_job_id":null,"html_url":"https://github.com/bubkoo/grunt-underscore-compiler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bubkoo/grunt-underscore-compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-underscore-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-underscore-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-underscore-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-underscore-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bubkoo","download_url":"https://codeload.github.com/bubkoo/grunt-underscore-compiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-underscore-compiler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266236964,"owners_count":23897298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T13:41:33.327Z","updated_at":"2025-07-21T04:08:15.087Z","avatar_url":"https://github.com/bubkoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-underscore-compiler\n\n\u003e Compile underscore templates into JavaScript files.\n\n## Getting Started\n\nThis plugin requires Grunt `~0.4.5`\n\nIf 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:\n\n```shell\nnpm install grunt-underscore-compiler --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-underscore-compiler');\n```\n\n## The \"underscore\" task\n\n### Overview\n\nIn your project's Gruntfile, add a section named `underscore_compiler` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  underscore: {\n    options: {\n      // Task-specific options go here.\n    },\n    your_target: {\n      // Target-specific file lists and/or options go here.\n    },\n  },\n});\n```\n\n### Options\n\n#### options.separator\n\nType: `String`\n\nDefault value: `linefeed + linefeed`\n\nConcatenated files will be joined on this string.\n\n#### options.indent\n\nType: `String`\n\nDefault value: `    `\n\nBy default 4 space indent is used for the generated code. \n\n#### options.quoteChar\n\nType: `String`\n\nDefault value: `'`\n\nStrings are quoted with single quote-only by default. However, for projects that want strict double-quotes usage, you can specify:\n\n```js\noptions: {\n    quoteChar: '\"'\n}\n```\n\n#### options.raw\n\nType: `Boolean`\n\nDefault value: `true`\n\nBy default keep the HTML line break in the generated code. You can specify this option to `false` to get one line code, but you note that this option is not equal to htmlmin.\n\n#### options.trim\n\nType: `Boolean`\n\nDefault value: `true`\n\nBy default trim each HTML line in the generated code, remove the space at the beginning and end for each line. You can specify this option to `false` to keep the space.\n\n#### options.namespace\n\nType: `String` or `false` or `Function`\n\nDefault value: `app.tpl`\n\nThe namespace in which the precompiled templates will be assigned. Use dot notation (e.g. App.Templates) for nested namespaces or false for no namespace wrapping. When false with amd option set true, templates will be returned directly from the AMD wrapper.\n\nExample:\n\n```js\noptions: {\n  namespace: 'MyApp.Templates'\n}\n```\nYou can generate nested namespaces based on the file system paths of your templates by providing a function. The function will be called with one argument (the template filepath). The function must return a dot notation based on the filepath.\n\n-The last array entry name derives from the `processName` option. The constructed final notation is `\u003coptions.global\u003e[\u003cnamespace\u003e][\u003cnamespace\u003e]...[\u003cprocessName\u003e]`\n\nExample:\n\n```js\noptions: {\n  namespace: function(filename) {\n    var names = filename.replace(/modules\\/(.*)(\\/\\w+\\.hbs)/, '$1');\n    return names.split('/').join('.');\n  },\n  processName: function(filename) {\n    return filename = filename.substring(filename.lastIndexOf('/') + 1, filename.lastIndexOf('.'));\n  }\n  demo: {\n  \tfiles: {\n    \t'ns_nested_tmpls.js' : [ 'modules/**/*.html']\n  \t}\n  }\n}\n```\n\n#### options.global\n\nType: `String`\n\nDefault value: `this`\n\nThe global object which the namespace belong to. \n\nExample:\n\n```js\noptions: {\n  namespace: 'MyApp.Templates',\n  global: 'this'\n}\n```\n\nThe generated code will like:\n\n\n```js\nthis[MyApp][Templates][SomeName] = 'your template';\n```\n\n#### options.amd\n\nType: `String` or `Boolean` or `Array`\n\nDefault value: `false`\n\nWraps the output file with an AMD define function and returns the compiled template namespace unless namespace has been explicitly set to false in which case the template function will be returned directly.\n\nIf String then that string will be used in the module definition `define(['your_amd_opt_here'])`.\n\nIf Array then those strings will be used in the module definition. \n\n#### options.compile\n\nType: `Boolean`\n\nDefault value: `false`\n\nBy default return the HTML string. Set to `true` will get precompiled template function.\n\n#### options.templateSettings\n\nType: `Object`\n\nDefault value: `{}`\n\n[underscore](http://underscorejs.org/#template)'s templateSettings.\n\n### Usage Examples\n\n```js\ngrunt.initConfig({\n  underscore: {\n    options: {\n        namespace: 'MyApp.Templates'\n    },\n    demo:{\n      files: {\n        'path/to/result.js': 'path/to/source.html',\n        'path/to/another.js': [\"path/to/sources/*.html', 'path/to/more/*.html']\n      }\n    }\n  }\n});\n```\n\n## Contributing\n\nIn 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/).\n\n## Release History\n\n- 2014-11-22   v0.0.1   Compile underscore templates into JavaScript files.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fgrunt-underscore-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbubkoo%2Fgrunt-underscore-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fgrunt-underscore-compiler/lists"}