Comments (8)
Why do you want that? Why removing comments during testing help you?
I think the preprocessor should try to preserve the original html as much
as possible. You can even have angular directive defined in a comment.
On Mon, Dec 9, 2013 at 11:09 AM, mcgraphix [email protected] wrote:
When converting the HTML to JS it would be really helpful to be able to
strip out any comments so they are not included in the resulting JS. If
this feature already exists, then it would be nice if it was more obvious
how to turn that on.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/19
.
from karma-ng-html2js-preprocessor.
Because we strip out comments in the final build to reduce the size using
the htmlmin option in grunt-html2js. Let's say I use the comment syntax for
a directive. All the tests would pass but the build version wouldn't
because the comments are no longer there. This isn't something that you
would want on by default but in our case it would catch this kind of error.
On Dec 10, 2013 10:01 PM, "Vojta Jina" [email protected] wrote:
Why do you want that? Why removing comments during testing help you?
I think the preprocessor should try to preserve the original html as much
as possible. You can even have angular directive defined in a comment.On Mon, Dec 9, 2013 at 11:09 AM, mcgraphix [email protected]
wrote:When converting the HTML to JS it would be really helpful to be able to
strip out any comments so they are not included in the resulting JS. If
this feature already exists, then it would be nice if it was more
obvious
how to turn that on.—
Reply to this email directly or view it on GitHub<
https://github.com/karma-runner/karma-ng-html2js-preprocessor/issues/19>
.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/19#issuecomment-30290159
.
from karma-ng-html2js-preprocessor.
This preprocessor was designed to the different purposes. Karma is the test runner, not a building tool.
@mcgraphix perhaps you need https://github.com/ericclemmons/grunt-angular-templates
from karma-ng-html2js-preprocessor.
I realize that it isn't a build tool. What I am saying though is that right now when we do a build using our other tools, our output as far as the html templates is concerned doesn't match the templates that were used when the tests were run. So, what I was hoping for was a way to make the tests use the compiled templates that are exactly like the ones that are in our final build. The way to do that would be, for our purposes, to allow comments to be stripped from the templates when the tests are run. I would expect that there would also be value in allowing for other HTML minifying options to be applied in testing as well, but our immediate need is to catch issues where if comment syntax is used for directives, the tests should fail because in production, the comments will be stripped.
from karma-ng-html2js-preprocessor.
@mcgraphix I hear what you are saying. You can try to do it and see how it works, if it's really helpful we can merge it in...
I think you might also have another suite that runs the tests using your production templates (for instance on the CI server). That would be much better imho....
from karma-ng-html2js-preprocessor.
We too run into a problem when there are comments in a template, the test will fail. Like...
template1 = $templateCache.get(modulePath+'social_sharing/templates/social_sharing.html');
element1 = $compile(template1)($scope1);
element1.scope().$apply();
By adding this line of code in escapeContent function to remove comments solves our prolbem
var escapeContent = function(content) {
content = content.replace(//g, "");
return content.replace(//g, '\').replace(/'/g, '\'').replace(/\r?\n/g, '\n' +\n '');
};
from karma-ng-html2js-preprocessor.
I can imagine that some people might want to remove comments / do other transformations on templates so those are closer to what gets deployed to prod. Having said this I don't think such functionality should be part of this processor. If someone needs this functionality it could be built into a different pre-processor. Such a separate pre-processor could be used to strip comments from non-angular templates as well (for example, to couple with the https://github.com/karma-runner/karma-html2js-preprocessor
Based on the above it would be -1 from me for building comments-removal logic into this pre-processor.
from karma-ng-html2js-preprocessor.
Closing based on the above comment.
from karma-ng-html2js-preprocessor.
Related Issues (20)
- Error: [$injector:modulerr] Failed to instantiate module app.templates HOT 3
- element.triggerHandler doesn't fire the element events together with templateUrl HOT 1
- Test pass only if singleRun is false HOT 1
- Uncaught ReferenceError: app is not defined and Error: [$injector:modulerr] Failed to instantiate module app due to:
- Unit test runs in PhantomJS but in chrome throws error RangeError: Maximum call stack size exceeded HOT 3
- Support for inline templates? HOT 2
- Need version bump HOT 2
- html2js-preprocessor fails if templateUrl: (elem, attr) => {return template};
- html2js-preprocessor adding relative template url HOT 2
- SyntaxError: Parse error - unexpected characters appears in the template js files HOT 1
- Needs error message when no templates found to render HOT 1
- Module is not created for external templates HOT 3
- JQuery parse errors with new line escapes HOT 1
- Parse errors when using single quotes HOT 1
- filepath.strip is not a function HOT 3
- Can't find variable when using jspm HOT 7
- having to create separate path and shim for every template with require.js
- moduleName as a function is not working correctly HOT 1
- Not working for me on Angular 2 RC2 HOT 1
- Issue with angular 2 RC6 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karma-ng-html2js-preprocessor.