Giter Site home page Giter Site logo

Comments (8)

vojtajina avatar vojtajina commented on September 28, 2024

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.

mcgraphix avatar mcgraphix commented on September 28, 2024

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.

lucassus avatar lucassus commented on September 28, 2024

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.

mcgraphix avatar mcgraphix commented on September 28, 2024

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.

vojtajina avatar vojtajina commented on September 28, 2024

@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.

playground avatar playground commented on September 28, 2024

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.

pkozlowski-opensource avatar pkozlowski-opensource commented on September 28, 2024

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.

pkozlowski-opensource avatar pkozlowski-opensource commented on September 28, 2024

Closing based on the above comment.

from karma-ng-html2js-preprocessor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.