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

Please consider remove the -p flag!

opened this issue · comments

If your templates use partials you should pass paths to partials using -p flag:

This is very much inconvenient, could you please add a feature that kill the -p flag? Please?

@phillipj
Thanks very much for your attention!

The situation is if a mustache template use partials, I have to pass paths to partials using -p flag, like this:

$ mustache -p path/to/partial1.mustache -p path/to/partial2.mustache dataView.json myTemplate.mustache

This is inconvenient because sometimes it's difficult to figure out what partials I've used in a template, what is worse is that even I have figured out that, I have to input a lot of words in the Terminal, it's very painful.

So I think there might be some way to not let a user to provide such information, because mustache.js can figure out them automatically:

-p path/to/partial1.mustache -p path/to/partial2.mustache

I see your point of having to provide potentially many partial arguments.

It would be interesting to hear what & how you would have expected mustache.js to know where partials are located.

The fact is I don't know, and that's why I asked for your help!

Ahh okey.

I can personally imagine this behaving in lots of different ways. The obvious factors would be folder structure, filenames and extensions. Those will vary from project to project, and what would work for the majority of projects isn't obvious until we've got insights from many projects.

With that in mind, I'm very hesitant implementing anything into mustache.js itself. At least until we've got more use cases at hand. And removing the -p argument from the command line tool we've got wouldn't help much as far as I'm concerned.

But, the above does not mean we can't help you. There's usually several ways to solve a challenge. More concrete details about what you're facing would be helpful tho..

  1. Are you able to run commands like $ node a-custom-script-using-mustache.js in your environment? Or are you strictly enforced to use the mustache executable?
  2. How does your folder structure & filenames look like?

Thanks for sharing!

A custom .js script could do what you're looking for in many different ways, without being overly complex. Let me know if you'd reconsider using such a .js script that you'd be in total control of ofcourse, rather than the mustache executable directly.

We found a third solution to this.

Great to hear you found something that suites your needs!

Handlebars.js has also been a great alternative for those who like mustache, but wants more opportunities.

I'm closing this issue for now, although for those who stumble upon this issue later and would like something similar, share your thoughts as feedback and other concrete use cases is a requirement for make this happen in mustache.js itself.

I like mustache more, handlebars is too heavy.