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

codeBlocks has no effect #69

Open
gultyayev opened this issue Mar 19, 2020 · 1 comment
Open

codeBlocks has no effect #69

gultyayev opened this issue Mar 19, 2020 · 1 comment

Comments

@gultyayev
Copy link

I'm having troubles parsing templates which have expressions like this {% if balance < 5 %}.
And the parsing is failing pointing to <.

I've tried to change the config to this

function inliner(css) {
  var css = fs.readFileSync(css).toString();
  var mqCss = siphon(css);

  var pipe = lazypipe()
    .pipe($.inlineCss, {
      applyStyleTags: false,
      removeStyleTags: true,
      preserveMediaQueries: true,
      removeLinkTags: false,
      codeBlocks: {
        HBS: { start: '{{', end: '}}' },
        volt: { start: '{%', end: '%}' },
        mustache: { start: '${{', end: '}}$' }
      }
    })
    .pipe($.replace, '<!-- <style> -->', `<style>${mqCss}</style>`)
    .pipe(
      $.replace,
      '<link rel="stylesheet" type="text/css" href="css/app.css">',
      ''
    )
    .pipe($.htmlmin, {
      collapseWhitespace: true,
      minifyCSS: true
    });

  return pipe();
}

But this doesn't seem to help.

@AzRieilStuff
Copy link

AzRieilStuff commented Sep 30, 2020

The point is here

const re = new RegExp(`${blocks[key].start}([\\S\\s]*?)${blocks[key].end}`, 'g');

You should escape spec. chars, one slash coz regex and one as it interpolated strings

volt: { start: '{\\%', end: '\\%}' },

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