janl / mustache.js

Minimal templating with {{mustaches}} in JavaScript

Home Page:https://mustache.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable CLI partial options to be renamed

nolanwrightdev opened this issue · comments

I'd like the -p flag to optionally accept a two-part argument, where one part is the path to the partial file and where the other part is a name for the partial. Renaming partials is currently possible only when using the library programmatically. This functionality would allow the CLI to mirror the following programmatic usage:

const template = `
  <div class="mmgr-navigation__competitions">
    {{#competitionList}}
      {{> select }}
    {{/competitionList}}
  </div>

  <div class="mmgr-navigation__schedule">
    {{#seasonList}}
      {{> select }}
    {{/seasonList}}
  </div>
`

const selectPartial = `
  <select class="mmgr-select">
    {{#.}}
      <option class="mmgr-select__item" value="{{value}}">{{text}}</option>
    {{/.}}
  </select>
`

const output = Mustache.render(template, data, { select: selectPartial })

I would be willing to submit a patch if the maintainers would like to incorporate this functionality.

Hi Nolan!

That indeed sounds reasonable 👍 Let me know if you need some help / thoughts opening a PR with related changes.