๐ Buy Me a Coffee โ
a-tarasyuk / broccoli-html2js Goto Github PK
View Code? Open in Web Editor NEWBroccoli plugin for convert AngularJS templates to JavaScript
License: MIT License
Broccoli plugin for convert AngularJS templates to JavaScript
License: MIT License
๐ Buy Me a Coffee โ
If the html is not minified it will span multiple lines. To form valid js, the result needs to look like:
var str = '<p>' +
' I am cool' +
'</p>';
Instead there are newlines in the string.
//var htmlJsStr = require('js-string-escape');
var htmlJsStr = function (string) {
return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function (character) {
// Escape all characters not included in SingleStringCharacters and
// DoubleStringCharacters on
// http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
switch (character) {
case '"':
case "'":
case '\\':
return '\\' + character
// Four possible LineTerminator characters need to be escaped:
case '\n':
return '\\n'
case '\r':
return '\\r'
case '\u2028':
return '\\u2028'
case '\u2029':
return '\\u2029'
}
})
}
var templates_js = html2js(templateDir, {
inputFiles: ['*.html',],
outputFile: '/templates.js', // or templates.coffee
replaceContent: htmlJsStr
});
error output on html input
Error: Parse Error: <img ng-src=\"{{chat.face}}\" style=\"width: 64px; height: 64px\">\n <p>\n {{chat.lastText}}\n </p>\n </ion-content>\n</ion-view>\n [string exception]
at /home/paul/myApp/node_modules/broccoli/lib/builder.js:35:15
at $$$internal$$tryCatch (/home/paul/myApp/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:490:16)
at $$$internal$$invokeCallback (/home/paul/myApp/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:502:17)
at $$$internal$$publish (/home/paul/myApp/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:473:11)
at $$$internal$$publishRejection (/home/paul/myApp/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:416:7)
at Object.$$rsvp$asap$$flush [as _onImmediate] (/home/paul/myApp/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:1581:9)
at processImmediate [as _immediateCallback] (timers.js:330:15)
I'm not really sure what is causing this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.