ericclemmons / grunt-angular-templates

Grunt build task to concatenate & pre-load your AngularJS templates
MIT License
710 stars 107 forks source link

Line breaks in attributes #144

Closed karensg closed 8 years ago

karensg commented 8 years ago

Hi,

Version 0.6 and 1.0.1 have some unexpected behavior for line breaks in attributes. Try the following:

<textarea placeholder="Line1
Line2"></textarea>

The output of the 0.5.9 and 0.6 is different. In version 0.6, the string of the first line is only closed on a new line which breaks the integration with ngAnnotate.

Btw: thanks for updating dependencies in 1.0. Very happy about it!

Karens

subhash85 commented 8 years ago

Yes, i have also faced the issue starting from version 0.6.0

underscorebrody commented 8 years ago

Thanks for reporting this, and sorry for the trouble! I'll take a look this morning.

On Mon, Jan 18, 2016 at 6:26 AM Subhash notifications@github.com wrote:

Yes, i have also faced the issue starting from version 0.6.0

— Reply to this email directly or view it on GitHub https://github.com/ericclemmons/grunt-angular-templates/issues/144#issuecomment-172502818 .

underscorebrody commented 8 years ago

@karensg or @subhash85 I'm trying to track down this issue, but running what you pasted above is giving identical results between 0.5.9 and 0.6 / 1.0. Can you provide additional detail about what's different in your results between the two version, and any additional options that might effect the output? Thanks!

karensg commented 8 years ago

Yes, of course.

ngtemplates: {
      dist: {
        options: {
          module: 'pluggdApp',
          htmlmin: '<%= htmlmin.dist.options %>',
          usemin: 'scripts/scripts.js'
        },
        cwd: '<%= yeoman.app %>',
        src: 'views/{,**/}*.html',
        dest: '.tmp/templateCache.js'
      }
    }

HTMLmin options:

options: {
          collapseWhitespace: true,
          conservativeCollapse: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeComments: true
        }

HTML that fails:

<textarea class="form-control form-area" maxlength="5000" name="bio" ng-model="artist.bio" ng-required="true" placeholder="Vertel de bezoeker je verhaal en wat jouw optreden uniek maakt.
Let op: verwijzingen naar andere websites of pagina's op sociale media worden verwijderd." tabindex="5"></textarea>
underscorebrody commented 8 years ago

@karensg can you also provide the correct result that you're seeing from 0.5.9 and indicate what 0.6.0 is doing wrong? Sorry for all the questions, but i'm having a hard time getting the two versions to produce different results. Thanks!

karensg commented 8 years ago

Thanks for looking at the issue. This is 0.6:

  $templateCache.put('views/artist/steps/_1.html',
    "<textarea class=\"form-control form-area\" maxlength=\"5000\" name=\"bio\" ng-model=\"artist.bio\" ng-required=\"true\" placeholder=\"Vertel de bezoeker je verhaal en wat jouw optreden uniek maakt.
" +
    "\n" +
    "Let op: verwijzingen naar andere websites of pagina's op sociale media worden verwijderd.\" tabindex=\"5\"></textarea>"
  );

This is 0.5.9

$templateCache.put('views/artist/steps/_1.html',
    "<textarea class=\"form-control form-area\" maxlength=\"5000\" name=\"bio\" ng-model=\"artist.bio\" ng-required=\"true\" placeholder=\"Vertel de bezoeker je verhaal en wat jouw optreden uniek maakt.\r" +
    "\n" +
    "Let op: verwijzingen naar andere websites of pagina's op sociale media worden verwijderd.\" tabindex=\"5\"></textarea>"
  );
underscorebrody commented 8 years ago

Oooh, interesting. It looks like it's the \r that's causing the problem, we aren't handling those. I'll put together something.

underscorebrody commented 8 years ago

@karensg Have a look at https://github.com/ericclemmons/grunt-angular-templates/pull/147 see if that fixes it for you

karensg commented 8 years ago

Yes, it fixes the problem. Thanks a lot.