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

Allow for multiple variables in template #13

Closed
nddery opened this issue Aug 30, 2014 · 3 comments
Closed

Allow for multiple variables in template #13

nddery opened this issue Aug 30, 2014 · 3 comments

Comments

@nddery
Copy link
Contributor

nddery commented Aug 30, 2014

Hi,

This is kind of related to issue #1. We are using RequireJS on a website and need to modify 2 attributes in our script tag: data-main and src.

Would something like this fit in your vision of the plugin (allowing to pass an array or replacement when using a template) ?

.pipe(htmlreplace({
  'rjs': {
    src: [data-main.js', 'require-src.js'],
    tpl: '<script data-main="%1$s" src="%2$s"></script>'
  }
}))

Cheers

@VFK
Copy link
Owner

VFK commented Aug 30, 2014

Hi Nicolas. This is actually a very good point. I'm thinking about something like this:

 rjs: {
          src: ['data-main.js', 'require-src.js'],
          tpl: '<script data-main="%s" src="%s"></script>'
      }

for single tag replacement and:

 rjs: {
          src: [['data-main.js', 'require-src.js'], ['script.js', 'script2.js']],
          tpl: '<script data-main="%s" src="%s"></script>'
      }

for multiple for continuity's sake.

If that's ok for you then i'm gonna add this in the future versions of the plugin. Will try to sort this all out as soon as i can :)

@nddery
Copy link
Contributor Author

nddery commented Aug 30, 2014

That would be perfect, I did not think about that multiple case - and I guess that's what tripping me up trying to implement this myself... It keeps adding multiple entries in the generated HTML.

If I do end up to get this working OK, I'll ensure to submit a PR.

Thanks!

@VFK
Copy link
Owner

VFK commented Aug 30, 2014

I merged your PR, thank you. I'm a gonna update the readme and publish the new version.

@VFK VFK closed this as completed Aug 30, 2014
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