Loading ...
Sorry, an error occurred while loading the content.

1033Re: [jslint] Re: JSLint doesn't like escaped newlines?

Expand Messages
  • Michael S. Mikowski
    Dec 22 1:46 PM
      I have found the following style construct:

      var htmlstring;

      ...

      htmlstring
      = '<h1>Title</h1>'
      + '<p>'
      + 'Some text'
      + '</p>'
      ;

      preferential for at least two reasons:

      1) When you use a compressor, like YUICompressor (you /are/ compressing your
      code, right?), the string is concatenated for you, so this actually takes up
      less space than the escaped carriage returns; and

      2) It is more readable without a performance penalty, as indentations are
      stripped during compression.

      Cheers, Mike


      On Monday 21 December 2009 03:37:59 pm Douglas Crockford wrote:
      > --- In jslint_com@yahoogroups.com, "jameswcryer" <emailthejames@...> wrote:
      > > var htmlstring = '\
      > > <h1>Title</h1>\
      > > <p>\
      > > Some text\
      > > </p>';
      > >
      > > Unfortunately the online JSLint app doesn't like this syntax, it provides
      > > the following error:
      > >
      > > Problem at line 1 character 20: Bad escapement.
      > >
      > > var htmlstring = '\
      > >
      > > May I ask if there is a reason for this or perhaps a limitation of the
      > > given UI?
      >
      > It is not allowed by the third edition of the standard.
      >
    • Show all 4 messages in this topic