dciccale / grunt-processhtml

Process html files at build time to modify them depending on the release environment
MIT License
407 stars 30 forks source link

Parse template tags in build value string #52

Closed dziamid closed 9 years ago

dziamid commented 10 years ago

Currently it seems that value string in build tags are not been processed as a template, so there's no means to pass options.data to value. So given we have this setup:

 <!-- index.html -->

<!-- build:[href]:prod <%= path %> -->
    <base href="index.html" />
 <!-- /build -->
#gruntfile
grunt.initConfig({
  processhtml: {
    prod: {
      options: {
          path: 'http://cdn.some.where/index.html'
      },
      files: {
        'dest/index.html': ['index.html']
      }
    }
  }
});

I would expect it to compile to:

    <base href="http://cdn.some.where/index.html" />
dciccale commented 10 years ago

It doesn't work that way.

You will need to first process the file as a template.

2014-09-20 11:50 GMT+02:00 Dziamid notifications@github.com:

Currently it seems that value string in build tags are not been processed as a template, so there's no means to pass options.data to value. So given we have this setup:

<base href="index.html" />

gruntfile

grunt.initConfig({ processhtml: { prod: { options: { path: 'http://cdn.some.where/index.html' }, files: { 'dest/index.html': ['index.html'] } } } });

I would expect it to compile to:

<base href="http://cdn.some.where/index.html" />

— Reply to this email directly or view it on GitHub https://github.com/dciccale/grunt-processhtml/issues/52.

dziamid commented 9 years ago

So, what is the result? Won't fix?

dciccale commented 9 years ago

You can use grunt itself for first processing that html file as a template so you can replace those variables, and after that process it through this plugin.

Is an edge case that doesn't fit in the scope of the plugin. if you need to do further work with that file, do what I suggested above.

dziamid commented 9 years ago

Oh, now it is clear. Thanks for pointing in!