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

dedent version of hbs? #622

Open
samselikoff opened this issue Jul 31, 2019 · 3 comments
Open

dedent version of hbs? #622

samselikoff opened this issue Jul 31, 2019 · 3 comments

Comments

@samselikoff
Copy link

Is there appetite for a version of hbs that dedents the template string?

I find myself often doing things like

layout: hbs(dedent`
  greeting: <span>{{greeting}}</span>
`)

with an npm package, but it always feels like extra work & is most of the time (always?) what I want.

You can see in Ember Animated's codebase Ed's forced to manually dedent the strings because he never got around to installing dedent, which kinda sucks.

Wondering if we could export an hbsd or hbsDedent tag that does this automatically.

layout: hbsDedent`
  greeting: <span>{{greeting}}</span>
`)

Watcha think?

Copy link
Member

rwjblue commented Aug 1, 2019

Unsure. I don't really like the idea that we'd have to provide a bunch of different hbsFoo style exports, but I am sensitive to the specific issue.

Specifically,dedent isn't really "good enough" here (also I much prefer stripIndent which I commonly use from common-tags npm package over dedent) since sometimes you want to effectively trim each line (leading and trailing spaces).

@samselikoff
Copy link
Author

I wish there was a way to customize tag functions. Not sure what it would look like.

Or maybe hbs could have some different properties that are different tags

hbs.stripIndent(`
  <p>Hello, foo</p>
`

Copy link
Member

rwjblue commented Aug 2, 2019

Ya, hbs.stripIndent "feels" vaguely better to me.

@rwjblue rwjblue transferred this issue from ember-cli/ember-cli-htmlbars-inline-precompile Oct 12, 2020
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