cgross / grunt-dom-munger

Grunt task to read and manipulate HTML with CSS selectors.
MIT License
93 stars 40 forks source link

options.read() get only needed ones #39

Open uloco opened 8 years ago

uloco commented 8 years ago

Can I configure the options.read() method to only get me the script tags I want to? If I got it right, I can only get all script tags' src attribute.

securityvoid commented 7 years ago

Yes, you can. You appear to be able to use selectors (Think its XPATH).

e.g. Don't read those items which have data-concat attribute set to false

dom_munger:{
      read: {
        options: {
          read:[
            {selector:'script[data-concat!="false"]',attribute:'src',writeto:'appjs'},
            {selector:'link[rel="stylesheet"][data-concat!="false"]',attribute:'href',writeto:'appcss'}
          ]
        },
        src: 'app/index.html'
      },