1

Recently we have started a wide scale upgrade of our EmberJS system. And currently we are at 2.11 version of ember. With EmberJS 2.11

Ember.HTMLBars.template

and

Ember.Handlebars.template

all come via a single template function and expect JSON (ie. compiled glimmer2 template)

Currently trying to get a simple "Hello world" message appeared. I have routes working, but Ember.HTMLBars.template expect glimmer2 JSON.

How do I make "Hello world" glimmer template and compile it to JSON?

Ember expects JSON something like

Ember.TEMPLATES["test/fixtures/simple"] = Ember.HTMLBars.template({"id":null,"block":"{\"statements\":[[\"open-element\",\"p\",[]],[\"flush-element\"],[\"text\",\"Hello, my name is \"],[\"append\",[\"unknown\",[\"name\"]],false],[\"text\",\".\"],[\"close-element\"]],\"locals\":[],\"named\":[],\"yields\":[],\"blocks\":[],\"hasPartials\":false}","meta":{}});

I have got https://github.com/tildeio/glimmer built, but not sure what to do next. At the end, I need to get basic hello_world.hbs to compile into JSON. I am a very new person in this area.

Any help appreciated

Thank you

Dimi

Dimi
  • 111
  • 5

1 Answers1

0

Not sure what the purpose of this is.

You can use ember-cli-htmlbars-inline-precompile to precompile a template like

const layout = hbs`{{if foo "bar" "baz"}}`;

Yeah, that's valid JS. See tagged template strings.

Then you can use the compiled template in a component like this:

import Component from 'ember-component';

export default Component.extend({
  layout;
});

There might be better options. Please read http://xyproblem.info , then provide details about your original problem.

Andrey Mikhaylov - lolmaus
  • 23,107
  • 6
  • 84
  • 133