ember-cli-htmlbars icon indicating copy to clipboard operation
ember-cli-htmlbars copied to clipboard

dedent version of `hbs`?

Open samselikoff opened this issue 6 years ago • 3 comments

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?

samselikoff avatar Jul 31 '19 19:07 samselikoff

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).

rwjblue avatar Aug 01 '19 14:08 rwjblue

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>
`

samselikoff avatar Aug 01 '19 20:08 samselikoff

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

rwjblue avatar Aug 02 '19 00:08 rwjblue