Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Handlebars for templating other than HTML?

I like how simple Handlebars is and how its design encourages the user to not put logic into the view. I have used it to template things other than HTML, but I am noticing the Handlebars.js website only discusses HTML examples. Is Handlebars only for templating HTML?

My IDE IntelliJ also only syntax checks/highlights my Handlebars files as HTML. I was hoping renaming my handlebars files with the intended extension as secondary (like Question.xml.hbs) would clue IntelliJ into my intentions, but it continued processing like I was editing HTML. There do not appear to be any pragmas in Handlebars for me to indicate what my target format or MIME type should be.

Architecturally, is it bad form to use Handlebars for purposes other than HTML templating? What if I restrict myself to HTML-like languages, like XML?

like image 996
DWoldrich Avatar asked Feb 03 '26 23:02

DWoldrich


1 Answers

Handlebars is used mostly with HTML. But you can change template language for a specified file in the IDEA settings. See:

enter image description here

Update: In the settings you can specify a template language to whole project.

like image 159
anstarovoyt Avatar answered Feb 06 '26 12:02

anstarovoyt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!