Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent line endings \n vs \r\n #73

Closed
SyntaxRules opened this issue Mar 13, 2015 · 1 comment
Closed

Inconsistent line endings \n vs \r\n #73

SyntaxRules opened this issue Mar 13, 2015 · 1 comment

Comments

@SyntaxRules
Copy link

Problem

I'm not sure if this is an oversight or an enhancement request.

Each time I run my gulp project it compiles my html files and puts it in the template cache for me. This works great! However, depending on the machine your template cache either has line endings as \r\n or \n. \r\n occurs on windows machines and \n occurs in linux/Mac machines. My template.js file is in version control so often the template.js file is checked in again even though there are no changes (besides line endings). Is there a way to normalize this so I only get line endings?

Proposed solution

Add a lineEndings setting, letting the user specify what it should always be. Maybe something like:

  return gulp.src(paths.templates)
    .pipe(addTemplates(paths.appName + '.templates.js', {
      module: paths.appName,
      lineEndings: '\n'
    }))
    .pipe(gulp.dest('js'));

Example

Example *.html files:

<p>Foo</p>
<p>bar</p>

Result on a windows machine:

angular.module("exampleApp").run(["$templateCache", function($templateCache) {$templateCache.put("example.html","<p>Foo</p>\r\n <p>Bar</p>");}]);

Result on Mac/Linux

angular.module("exampleApp").run(["$templateCache", function($templateCache) {$templateCache.put("example.html","<p>Foo</p>\n <p>Bar</p>");}]);
@miickel
Copy link
Owner

miickel commented Mar 25, 2015

Generally, before piping your HTML to this plugin you should minify it using a HTML minifying gulp plugin. We do not touch your HTML, other than converting it to a JavaScript string. It's in line with the gulp plugin philosophy that a plugin should do one thing and one thing only (which is why we do not minify the HTML for you).

So if you use some template engine, the problem is there. Otherwise try looking into a HTML minifying plugin.

@miickel miickel closed this as completed Mar 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants