diff --git a/README.md b/README.md index 9172120..a6de516 100644 --- a/README.md +++ b/README.md @@ -1,107 +1,12 @@ jade-angularjs-brunch [![Build Status](https://travis-ci.org/GulinSS/jade-angularjs-brunch.png?branch=master)](https://travis-ci.org/GulinSS/jade-angularjs-brunch) ===================== -Compiler Jade templates to AngularJS modules for Brunch.IO with automatic section detection based on location of index.jade's. +DEPRECATED! Need update! +======================== -## Step by step using guide +Automatic compiler Jade templates to AngularJS modules for Brunch.IO -For example you have a directory structure of your project such as: - -``` -app/ - index.jade - application.coffee - welcome/ - page.jade - page.less - controllers.coffee - directives.coffee - otherStuff.coffee - access/ - index.jade - application.coffee - register/ - page.jade - page.less - controllers.coffee - directives.coffee - otherStuff.coffee - login/ - ... - admin/ - index.jade - application.coffee - users/ - ... - records/ - ... - landing/ - index.jade - ... - -``` - -The key note of example above is location of index.jade's. Them will be compile as usual jade files into index.html's. Your public folder will have such structure: - -``` -_public/ - index.html - access/ - index.html - admin/ - index.html - landing/ - index.html - -``` - -And as addition it will group "partials" (files like page.jade in example) of this section into javascript files: - -``` -_public/ - js/ - app.templates.js # it will contains compiled content of - # app/welcome/page.jade and any jades in subdirectories - - app.access.templates.js # it will contains compiled content of - # app/access/register/page.jade and - # app/access/login/page.jade - # and any jades in subdirectories - - app.admin.templates.js # ... - ... -``` - -Any file in example above will contains declaration of Angular.js module with same name: - -``` -app.templates.js -> app.templates -app.access.templates.js -> app.access.templates -... -``` - -Modules must be registered in application.coffee's files such as: - -``` -App = angular.module('app', [ - ... - - 'app.templates' -]) -``` - -After action above you can use your template in your code like this: - -``` - $routeProvider - .when('/welcome', {templateUrl: 'app/welcome/page.jade'}) -``` - -or in directive's templateUrl. - -This magic helps you split your large application on small SPA sections for improving performance and control complexity. - -## Sample of settings (DEPRECATED) +## Sample of settings: ### Add to dependencies section in package.json of your project: @@ -146,6 +51,62 @@ angular.module('login.templates', []) 'This is content of your jade-file',''].join("\n")); }]) ``` +# Specific Output Directory + +You can now specify the output directory of the compiled files using the `output_directory` property of the config +```coffee +plugins: +plugins: + jade_angular: + output_directory: 'foo' +``` + + +# Angular Module Config + +You can add an angular module namespace to all templates using the `angular_module` property. + +```coffee +jade_angular: + single_file: false + angular_module + namespace: 'myLibrary' + predefined: false +``` +This will create template files with namespaced modules instead of using directory structure. + +```javascript +angular.module('myLibrary.templates', []) +.run([ '$templateCache', function($templateCache) { + return $templateCache.put('myLibrary/templates/hello.html', [ +'', +'
', +'

Hello, World!

', +'
',''].join("\n")); +}]); +``` + +You can also specify whether or not the angular module has been predfined using the `predefined` property + +```coffee +jade_angular: + single_file: false + angular_module + namespace: 'myLibrary' + predefined: true +``` + +```javascript +angular.module('myLibrary.templates') +.run([ '$templateCache', function($templateCache) { + return $templateCache.put('myLibrary/templates/hello.html', [ +'', +'
', +'

Hello, World!

', +'
',''].join("\n")); +}]); +``` + # Single-File Mode @@ -153,8 +114,8 @@ If you want a single file instead of a file per module, you can use the `single_ ```coffee plugins: - jade_angular: - single_file: true + jade_angular: single_file: true # if you want to change the file name (defaults to js/templates.js and is in your public directory) single_file_name: 'js/angular_templates.js' + ``` diff --git a/lib/index.js b/lib/index.js index a41c7fa..630163f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,251 +1,265 @@ -// Generated by CoffeeScript 1.3.3 -(function() { - var JadeAngularJsCompiler, fileWriter, fs, jade, mkdirp, sysPath, _; +// Generated by CoffeeScript 1.6.3 +var JadeAngularJsCompiler, fileWriter, fs, jade, mkdirp, sysPath, _; - jade = require('jade'); +jade = require('jade'); - sysPath = require('path'); +sysPath = require('path'); - mkdirp = require('mkdirp'); +mkdirp = require('mkdirp'); - fs = require('fs'); +fs = require('fs'); - _ = require('lodash'); +_ = require('lodash'); - fileWriter = function(newFilePath) { - return function(err, content) { - var dirname; +fileWriter = function(newFilePath) { + return function(err, content) { + var dirname; + if (err != null) { + throw err; + } + if (content == null) { + return; + } + dirname = sysPath.dirname(newFilePath); + return mkdirp(dirname, '0775', function(err) { if (err != null) { throw err; } - if (!(content != null)) { - return; - } - dirname = sysPath.dirname(newFilePath); - return mkdirp(dirname, '0775', function(err) { + return fs.writeFile(newFilePath, content, function(err) { if (err != null) { throw err; } - return fs.writeFile(newFilePath, content, function(err) { - if (err != null) { - throw err; - } - }); }); - }; + }); }; +}; - module.exports = JadeAngularJsCompiler = (function() { +module.exports = JadeAngularJsCompiler = (function() { + JadeAngularJsCompiler.prototype.brunchPlugin = true; - JadeAngularJsCompiler.prototype.brunchPlugin = true; + JadeAngularJsCompiler.prototype.type = 'template'; - JadeAngularJsCompiler.prototype.type = 'template'; + JadeAngularJsCompiler.prototype.extension = 'jade'; - JadeAngularJsCompiler.prototype.extension = 'jade'; + function JadeAngularJsCompiler(config) { + var _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + this["public"] = ((_ref = config.paths) != null ? _ref["public"] : void 0) || "_public"; + this.pretty = !!((_ref1 = config.plugins) != null ? (_ref2 = _ref1.jade) != null ? _ref2.pretty : void 0 : void 0); + this.doctype = ((_ref3 = config.plugins) != null ? (_ref4 = _ref3.jade) != null ? _ref4.doctype : void 0 : void 0) || "5"; + this.locals = ((_ref5 = config.plugins) != null ? (_ref6 = _ref5.jade_angular) != null ? _ref6.locals : void 0 : void 0) || {}; + this.staticMask = ((_ref7 = config.plugins) != null ? (_ref8 = _ref7.jade_angular) != null ? _ref8.static_mask : void 0 : void 0) || /index.jade/; + this.compileTrigger = sysPath.normalize(this["public"] + sysPath.sep + (((_ref9 = config.paths) != null ? _ref9.jadeCompileTrigger : void 0) || 'js/dontUseMe')); + this.singleFile = !!(config != null ? (_ref10 = config.plugins) != null ? (_ref11 = _ref10.jade_angular) != null ? _ref11.single_file : void 0 : void 0 : void 0); + this.singleFileName = sysPath.join(this["public"], (config != null ? (_ref12 = config.plugins) != null ? (_ref13 = _ref12.jade_angular) != null ? _ref13.single_file_name : void 0 : void 0 : void 0) || "js/angular_templates.js"); + this.angularModule = ((_ref14 = config.plugins) != null ? (_ref15 = _ref14.jade_angular) != null ? _ref15.angular_module : void 0 : void 0) || {}; + this.outputDirectory = ((_ref16 = config.plugins) != null ? (_ref17 = _ref16.jade_angular) != null ? _ref17.output_directory : void 0 : void 0) || 'js'; + } - function JadeAngularJsCompiler(config) { - var _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; - this["public"] = ((_ref = config.paths) != null ? _ref["public"] : void 0) || "_public"; - this.pretty = !!((_ref1 = config.plugins) != null ? (_ref2 = _ref1.jade) != null ? _ref2.pretty : void 0 : void 0); - this.doctype = ((_ref3 = config.plugins) != null ? (_ref4 = _ref3.jade) != null ? _ref4.doctype : void 0 : void 0) || "5"; - this.locals = ((_ref5 = config.plugins) != null ? (_ref6 = _ref5.jade_angular) != null ? _ref6.locals : void 0 : void 0) || {}; - this.staticMask = ((_ref7 = config.plugins) != null ? (_ref8 = _ref7.jade_angular) != null ? _ref8.static_mask : void 0 : void 0) || /index.jade/; - this.compileTrigger = sysPath.normalize(this["public"] + sysPath.sep + (((_ref9 = config.paths) != null ? _ref9.jadeCompileTrigger : void 0) || 'js/dontUseMe')); - this.singleFile = !!(config != null ? (_ref10 = config.plugins) != null ? (_ref11 = _ref10.jade_angular) != null ? _ref11.single_file : void 0 : void 0 : void 0); - this.singleFileName = sysPath.join(this["public"], (config != null ? (_ref12 = config.plugins) != null ? (_ref13 = _ref12.jade_angular) != null ? _ref13.single_file_name : void 0 : void 0 : void 0) || "js/angular_templates.js"); + JadeAngularJsCompiler.prototype.compile = function(data, path, callback) { + var content, err, error; + try { + content = jade.compile(data, { + compileDebug: false, + client: false, + filename: path, + doctype: this.doctype, + pretty: this.pretty + }); + return content(this.locals); + } catch (_error) { + err = _error; + return error = err; + } finally { + callback(error, ""); } + }; - JadeAngularJsCompiler.prototype.compile = function(data, path, callback) { - var content, error; - try { - content = jade.compile(data, { - compileDebug: false, - client: false, - filename: path, - doctype: this.doctype, - pretty: this.pretty - }); - return content(this.locals); - } catch (err) { - return error = err; - } finally { - callback(error, ""); - } - }; - - JadeAngularJsCompiler.prototype.preparePairStatic = function(pair) { - pair.path.push(pair.path.pop().slice(0, -this.extension.length) + 'html'); - return pair.path.splice(0, 1, this["public"]); - }; - - JadeAngularJsCompiler.prototype.writeStatic = function(pairs) { - var _this = this; - return _.each(pairs, function(pair) { - var writer; - _this.preparePairStatic(pair); - writer = fileWriter(sysPath.join.apply(_this, pair.path)); - return writer(null, pair.result); - }); - }; + JadeAngularJsCompiler.prototype.preparePairStatic = function(pair) { + pair.path.push(pair.path.pop().slice(0, -this.extension.length) + 'html'); + return pair.path.splice(0, 1, this["public"]); + }; - JadeAngularJsCompiler.prototype.parsePairsIntoAssetsTree = function(pairs) { - var assets, root, - _this = this; - assets = _.map(pairs, function(v) { - return _this.removeFileNameFromPath(v.path); - }); - root = []; - _.each(assets, function(path) { - var node; - node = root; - return _.each(path, function(v) { - var child; - child = _.find(node, function(vv) { - return vv.name === v; - }); - if (child === void 0) { - child = { - name: v, - children: [] - }; - node.push(child); - } - return node = child.children; - }); - }); - return root; - }; + JadeAngularJsCompiler.prototype.writeStatic = function(pairs) { + var _this = this; + return _.each(pairs, function(pair) { + var writer; + _this.preparePairStatic(pair); + writer = fileWriter(sysPath.join.apply(_this, pair.path)); + return writer(null, pair.result); + }); + }; - JadeAngularJsCompiler.prototype.attachModuleNameToTemplate = function(pair, assetsTree) { - var findedPath, node, path; - path = this.removeFileNameFromPath(pair.path); - if (assetsTree.length === 0) { - pair.module = "" + path[0] + ".templates"; - return; - } - findedPath = []; - node = assetsTree; - _.each(path, function(v) { + JadeAngularJsCompiler.prototype.parsePairsIntoAssetsTree = function(pairs) { + var assets, root, + _this = this; + assets = _.map(pairs, function(v) { + return _this.removeFileNameFromPath(v.path); + }); + root = []; + _.each(assets, function(path) { + var node; + node = root; + return _.each(path, function(v) { var child; child = _.find(node, function(vv) { return vv.name === v; }); if (child === void 0) { - return; + child = { + name: v, + children: [] + }; + node.push(child); } - findedPath.push(child.name); return node = child.children; }); - findedPath.push("templates"); - return pair.module = findedPath.join('.'); - }; + }); + return root; + }; - JadeAngularJsCompiler.prototype.removeFileNameFromPath = function(path) { - return path.slice(0, -1); - }; + JadeAngularJsCompiler.prototype.attachModuleNameToTemplate = function(pair, assetsTree) { + var findedPath, node, path; + path = this.removeFileNameFromPath(pair.path); + if (this.angularModule.namespace) { + pair.module = this.angularModule.namespace + '.templates'; + return; + } + if (assetsTree.length === 0) { + pair.module = "" + path[0] + ".templates"; + return; + } + findedPath = []; + node = assetsTree; + _.each(path, function(v) { + var child; + child = _.find(node, function(vv) { + return vv.name === v; + }); + if (child === void 0) { + return; + } + findedPath.push(child.name); + return node = child.children; + }); + findedPath.push("templates"); + return pair.module = findedPath.join('.'); + }; - JadeAngularJsCompiler.prototype.generateModuleFileName = function(module) { - return module.filename = sysPath.join.apply(this, [this["public"], 'js', module.name + ".js"]); - }; + JadeAngularJsCompiler.prototype.removeFileNameFromPath = function(path) { + return path.slice(0, -1); + }; + + JadeAngularJsCompiler.prototype.generateModuleFileName = function(module) { + return module.filename = sysPath.join.apply(this, [this["public"], this.outputDirectory, module.name + ".js"]); + }; - JadeAngularJsCompiler.prototype.writeModules = function(modules) { - var buildModule, content, writer; - buildModule = function(module) { - var addEndOfModule, content, moduleHeader, templateRecord; - moduleHeader = function(name) { + JadeAngularJsCompiler.prototype.writeModules = function(modules) { + var buildModule, content, predefined, singleFile, writer; + predefined = this.angularModule.predefined; + buildModule = function(module) { + var addEndOfModule, content, moduleHeader, templateRecord; + moduleHeader = function(name) { + if (!predefined) { return "angular.module('" + name + "', [])"; - }; - templateRecord = function(result, path) { - var parseStringToJSArray; - parseStringToJSArray = function(str) { - var stringArray; - stringArray = '['; - str.split('\n').map(function(e, i) { - return stringArray += "\n'" + e.replace(/'/g, "\\'") + "',"; - }); - return stringArray += "''" + '].join("\\n")'; - }; - return "\n.run(['$templateCache', function($templateCache) {\n return $templateCache.put('" + path + "', " + (parseStringToJSArray(result)) + ");\n}])"; - }; - addEndOfModule = function() { - return ";\n"; - }; - content = moduleHeader(module.name); - _.each(module.templates, function(template) { - return content += templateRecord(template.result, template.path); - }); - return content += addEndOfModule(); - }; - content = ""; - _.each(modules, function(module) { - var moduleContent, writer; - moduleContent = buildModule(module); - if (this.singleFile) { - return content += "\n" + moduleContent; } else { - writer = fileWriter(module.filename); - return writer(null, moduleContent); + return "angular.module('" + name + "')"; } - }); - if (this.singleFile) { - writer = fileWriter(this.singleFileName); - return writer(null, content); - } - }; - - JadeAngularJsCompiler.prototype.prepareResult = function(compiled) { - var pathes, - _this = this; - pathes = _.find(compiled, function(v) { - return v.path === _this.compileTrigger; - }); - if (pathes === void 0) { - return []; - } - return pathes.sourceFiles.map(function(e, i) { - var content, data; - data = fs.readFileSync(e.path, 'utf8'); - content = jade.compile(data, { - compileDebug: false, - client: false, - filename: e.path, - doctype: _this.doctype, - pretty: _this.pretty - }); - return { - path: e.path.split(sysPath.sep), - result: content(_this.locals) + }; + templateRecord = function(result, path) { + var parseStringToJSArray; + parseStringToJSArray = function(str) { + var stringArray; + stringArray = '['; + str.split('\n').map(function(e, i) { + return stringArray += "\n'" + e.replace(/'/g, "\\'") + "',"; + }); + return stringArray += "''" + '].join("\\n")'; }; + return "\n.run([ '$templateCache', function($templateCache) {\n return $templateCache.put('" + path + "', " + (parseStringToJSArray(result)) + ");\n}])"; + }; + addEndOfModule = function() { + return ";\n"; + }; + content = moduleHeader(module.name); + _.each(module.templates, function(template) { + return content += templateRecord(template.result, template.path); }); + return content += addEndOfModule(); }; + content = ""; + singleFile = this.singleFile; + _.each(modules, function(module) { + var moduleContent, writer; + moduleContent = buildModule(module); + if (singleFile) { + return content += "\n" + moduleContent; + } else { + writer = fileWriter(module.filename); + return writer(null, moduleContent); + } + }); + if (this.singleFile) { + writer = fileWriter(this.singleFileName); + return writer(null, content); + } + }; - JadeAngularJsCompiler.prototype.onCompile = function(compiled) { - var assets, assetsTree, preResult, - _this = this; - preResult = this.prepareResult(compiled); - assets = _.filter(preResult, function(v) { - return _this.staticMask.test(v.path); + JadeAngularJsCompiler.prototype.prepareResult = function(compiled) { + var pathes, + _this = this; + pathes = _.find(compiled, function(v) { + return v.path === _this.compileTrigger; + }); + if (pathes === void 0) { + return []; + } + return pathes.sourceFiles.map(function(e, i) { + var content, data, path; + data = fs.readFileSync(e.path, 'utf8'); + content = jade.compile(data, { + compileDebug: false, + client: false, + filename: e.path, + doctype: _this.doctype, + pretty: _this.pretty }); - assetsTree = this.parsePairsIntoAssetsTree(assets); - this.writeStatic(assets); - return this.writeModules(_.chain(preResult).difference(assets).each(function(v) { - return _this.attachModuleNameToTemplate(v, assetsTree); - }).each(function(v) { - return v.path = v.path.join('/'); - }).groupBy(function(v) { - return v.module; - }).map(function(v, k) { - return { - name: k, - templates: v - }; - }).each(function(v) { - return _this.generateModuleFileName(v); - }).value()); - }; + path = e.path.split(sysPath.sep); + if (_this.angularModule.namespace) { + path[0] = _this.angularModule.namespace; + } + return { + path: path, + result: content(_this.locals) + }; + }); + }; - return JadeAngularJsCompiler; + JadeAngularJsCompiler.prototype.onCompile = function(compiled) { + var assets, assetsTree, preResult, + _this = this; + preResult = this.prepareResult(compiled); + assets = _.filter(preResult, function(v) { + return _this.staticMask.test(v.path); + }); + assetsTree = this.parsePairsIntoAssetsTree(assets); + this.writeStatic(assets); + return this.writeModules(_.chain(preResult).difference(assets).each(function(v) { + return _this.attachModuleNameToTemplate(v, assetsTree); + }).each(function(v) { + v.path.push(v.path.pop().slice(0, -_this.extension.length) + 'html'); + return v.path = v.path.join('/'); + }).groupBy(function(v) { + return v.module; + }).map(function(v, k) { + return { + name: k, + templates: v + }; + }).each(function(v) { + return _this.generateModuleFileName(v); + }).value()); + }; - })(); + return JadeAngularJsCompiler; -}).call(this); +})(); diff --git a/package.json b/package.json index 000278e..e25404c 100644 --- a/package.json +++ b/package.json @@ -30,5 +30,16 @@ "chai": "*", "sinon": "~1.7.3", "sinon-chai": "~2.4.0" - } + }, + "readme": "jade-angularjs-brunch [![Build Status](https://travis-ci.org/GulinSS/jade-angularjs-brunch.png?branch=master)](https://travis-ci.org/GulinSS/jade-angularjs-brunch)\n=====================\n\nDEPRECATED! Need update!\n========================\n\nAutomatic compiler Jade templates to AngularJS modules for Brunch.IO\n\n## Sample of settings:\n\n### Add to dependencies section in package.json of your project:\n\n`` \"jade-angularjs-brunch\" : \">= 0.0.1 < 1.5\" `` \n\n### Add to paths section in config.coffee:\n\n```coffee\njadeCompileTrigger: '.compile-jade' # Defaults to 'js/dontUseMe'.\n```\n\n### Add to templates section in config.coffee:\n\n```coffee\njoinTo: \n '.compile-jade': /^app/ # Hack for auto-compiling Jade templates.\n```\n\n### Add to plugin section in config.coffee:\n\n```coffee\nplugins:\n jade:\n pretty: yes # Adds pretty-indentation whitespaces to output (false by default).\n doctype: \"xml\" # Specify doctype (\"5\" by default).\n jade_angular:\n modules_folder: 'templates'\n locals: {}\n```\n\n* modules_folder: folder with your template\n* locals: context for jade compiler\n\n### Now you can get angular.js modules:\n\n_public/js/login.template.js:\n\n```js\nangular.module('login.templates', [])\n.run(['$templateCache', function($templateCache) {\n return $templateCache.put('/login/modal.page.html', [\n'This is content of your jade-file',''].join(\"\\n\"));\n}])\n```\n\n# Single-File Mode\n\nIf you want a single file instead of a file per module, you can use the `single_file` option in `jade_angular`.\n\n```coffee\nplugins:\n jade_angular:\n single_file: true\n # if you want to change the file name (defaults to js/templates.js and is in your public directory)\n single_file_name: 'js/angular_templates.js'\n```\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/GulinSS/jade-angularjs-brunch/issues" + }, + "_id": "jade-angularjs-brunch@1.1.1", + "_from": "jade-angularjs-brunch@1.1.1", + "dist": { + "shasum": "93d3372c6f8b4a4bf1d0a4cf87dc18bc4a187680" + }, + "_resolved": "https://registry.npmjs.org/jade-angularjs-brunch/-/jade-angularjs-brunch-1.1.1.tgz" } diff --git a/src/index.coffee b/src/index.coffee index 9f4a814..1a940ed 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -27,6 +27,8 @@ module.exports = class JadeAngularJsCompiler @compileTrigger = sysPath.normalize @public + sysPath.sep + (config.paths?.jadeCompileTrigger or 'js/dontUseMe') @singleFile = !!config?.plugins?.jade_angular?.single_file @singleFileName = sysPath.join @public, (config?.plugins?.jade_angular?.single_file_name or "js/angular_templates.js") + @angularModule = config.plugins?.jade_angular?.angular_module or {} + @outputDirectory = config.plugins?.jade_angular?.output_directory or 'js' # Do nothing, just check possibility of Jade compilation compile: (data, path, callback) -> @@ -78,8 +80,12 @@ module.exports = class JadeAngularJsCompiler attachModuleNameToTemplate: (pair, assetsTree) -> path = @removeFileNameFromPath pair.path + if @angularModule.namespace + pair.module = @angularModule.namespace + '.templates'; + return; + if assetsTree.length is 0 - pair.module ="#{path[0]}.templates" + pair.module = "#{path[0]}.templates" return findedPath = [] @@ -98,15 +104,20 @@ module.exports = class JadeAngularJsCompiler removeFileNameFromPath: (path) -> path[0..-2] generateModuleFileName: (module) -> - module.filename = sysPath.join.apply(this, [@public, 'js', module.name+".js"]) + module.filename = sysPath.join.apply(this, [@public, @outputDirectory, module.name+".js"]) writeModules: (modules) -> - + predefined = @angularModule.predefined buildModule = (module) -> moduleHeader = (name) -> - """ - angular.module('#{name}', []) - """ + if !predefined + """ + angular.module('#{name}', []) + """ + else + """ + angular.module('#{name}') + """ templateRecord = (result, path) -> parseStringToJSArray = (str) -> @@ -116,7 +127,7 @@ module.exports = class JadeAngularJsCompiler stringArray += "''" + '].join("\\n")' """ - \n.run(['$templateCache', function($templateCache) { + \n.run([ '$templateCache', function($templateCache) { return $templateCache.put('#{path}', #{parseStringToJSArray(result)}); }]) """ @@ -131,12 +142,14 @@ module.exports = class JadeAngularJsCompiler content += addEndOfModule() content = "" - + singleFile = @singleFile _.each modules, (module) -> + moduleContent = buildModule module - - if @singleFile + + if singleFile content += "\n#{moduleContent}" + else writer = fileWriter module.filename writer null, moduleContent @@ -144,7 +157,6 @@ module.exports = class JadeAngularJsCompiler if @singleFile writer = fileWriter @singleFileName writer null, content - prepareResult: (compiled) -> pathes = _.find compiled, (v) => v.path is @compileTrigger @@ -159,7 +171,12 @@ module.exports = class JadeAngularJsCompiler doctype: @doctype pretty: @pretty - path: e.path.split sysPath.sep + path = e.path.split sysPath.sep + + if @angularModule.namespace + path[0] = @angularModule.namespace; + + path: path result: content @locals onCompile: (compiled) -> @@ -173,7 +190,10 @@ module.exports = class JadeAngularJsCompiler @writeModules _.chain(preResult) .difference(assets) .each((v) => @attachModuleNameToTemplate v, assetsTree) - .each((v) -> v.path = v.path.join('/')) # concat items to virtual url + .each((v) => + v.path.push(v.path.pop()[...-@extension.length] + 'html') + v.path = v.path.join('/') + ) # concat items to virtual url .groupBy((v) -> v.module) .map((v, k) -> name: k, templates: v) .each((v) => @generateModuleFileName v)