├── package.js ├── README.md ├── .gitignore ├── LICENSE └── plugin.js /package.js: -------------------------------------------------------------------------------- 1 | Package.describe({ 2 | name: "civilframe:angular-jade", 3 | summary: "Jade templating for Meteor-Angular", 4 | version: "0.0.3", 5 | git: "https://github.com/civilframe/meteor-angular-jade.git" 6 | }); 7 | 8 | Package.registerBuildPlugin({ 9 | name: "compileJadeAngular", 10 | sources: [ 11 | 'plugin.js' 12 | ], 13 | npmDependencies : { 14 | 'html-minifier': '0.7.2', 15 | 'jade': '1.9.2' 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | !! COMPATIBLE WITH METEOR 1.2 and EARLIER 2 | 3 | # meteor-angular-jade 4 | Compile Jade templates for use in meteor-angular, with Angular 1.x. 5 | 6 | ### Prerequisites 7 | For use with angular-meteor only. https://github.com/Urigo/angular-meteor 8 | 9 | ### Installation 10 | ```meteor add civilframe:angular-jade``` 11 | 12 | ### Usage 13 | Files ending in *.ng.jade and will be compiled to *.html 14 | 15 | For example, "templates/directives/editUserForm.ng.jade" will be compiled to "templates/directives/editUserForm.html", so you'll want to reference it as such in Angular. 16 | 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | 30 | .npm 31 | .versions -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Alex Solo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /plugin.js: -------------------------------------------------------------------------------- 1 | var minify = Npm.require('html-minifier').minify; 2 | var jade = Npm.require('jade'); 3 | var jadeOpts = {pretty:true, compileDebug:false}; 4 | 5 | Plugin.registerSourceHandler('ng.jade', { 6 | isTemplate: true, 7 | archMatching: 'web' 8 | }, function(compileStep) { 9 | var contents = compileStep.read().toString('utf8'); 10 | jadeOpts.filename = compileStep.fullInputPath; 11 | contents = jade.compile(contents, jadeOpts)(); 12 | 13 | var newPath = compileStep.inputPath; 14 | newPath = newPath.replace(/\\/g, "/"); 15 | newPath = newPath.replace(".ng.jade", ".html"); 16 | 17 | var results = 'angular.module(\'angular-meteor\').run([\'$templateCache\', function($templateCache) {' + 18 | '$templateCache.put(\'' + newPath + '\', \'' + 19 | minify(contents.replace(/'/g, "\\'"), { 20 | collapseWhitespace : true, 21 | conservativeCollapse : true, 22 | removeComments : true, 23 | minifyJS : true, 24 | minifyCSS: true, 25 | processScripts : ['text/ng-template'] 26 | }) + '\');' + 27 | '}]);'; 28 | 29 | compileStep.addJavaScript({ 30 | path : newPath, 31 | data : results.replace(/\n/g, '\\n'), 32 | sourcePath : compileStep.inputPath 33 | }); 34 | }); 35 | --------------------------------------------------------------------------------