marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.36k stars 643 forks source link

Does exists a text only / no host functionality? #1269

Closed StarpTech closed 5 years ago

StarpTech commented 5 years ago

Imagine following use case: I would like to provide a translation component which accept one property i18n and translate the value. I can't use

translation.marko

${out.global.res.__(input.i18n)}

because markojs is trying to find a dynamic component which is in my opinion also wrong because tags starts with <. The workaround is to wrap it with a html tag but this can't be the solution. I can't use makros because the tag must be available globally.

StarpTech commented 5 years ago

This can be solved by a custom renderer e.g link but how can I avoid that it will be transferred to the browser? Therefore using compiler hooks is not recommended by the markojs team.

StarpTech commented 5 years ago

The solution is already documented in https://markojs.com/docs/syntax/. We have to use the concise syntax -- to host text only in a tag template.