pdb icon indicating copy to clipboard operation
pdb copied to clipboard

pdb_ember: Ember hello world

Open mrjmd opened this issue 8 years ago • 5 comments

Let's evaluate what it will take to get a basic hello world module / example component out there in Ember.

mrjmd avatar Apr 08 '16 13:04 mrjmd

I'm totally new to Ember.js but it appears to expect to control the complete page. I did a bit of Googling and it also appears you can set the root element. That said, I have a few questions to consider:

  • When using Ember in multiple blocks on a single page even possible?
  • Would each block be it's own app?
  • Could multiple blocks be aware of each other?

kepford avatar Apr 27 '16 20:04 kepford

Setting the root element is as easy as this.

App = Ember.Application.extend({
  rootElement: "emberexample1",
});

This will tell Ember to attach its application to a tag named <emberexample1>.

kepford avatar May 02 '16 02:05 kepford

What I'm trying to figure out is what we should render from Drupal and what should be added to the page by Ember. Most examples I find use <script> tags to allow Handlebars.js to populate the area of the page with content from the Ember templates.

I believe we could include a template file in the Ember example that would output the script tags, but this seems to Drupal specific. Now the Front end developer needs to use Twig.

I'm trying to learn more about Ember and how it builds a page to determine what the best method would be.

kepford avatar May 02 '16 02:05 kepford

Acourding to the Ember docs on templating if you aren't using build tools it's cool to use script tags. This seems like it would be a problem though with Twig.

    <script type="text/x-handlebars">
      Hello, <strong>{{firstName}} {{lastName}}</strong>!
    </script>

Handlebars uses {{variable}} as Twig does.

kepford avatar May 02 '16 02:05 kepford

Pushed my work in progress branch. https://github.com/mrjmd/pdb/tree/feature/12-Ember-Hello-World

kepford avatar May 02 '16 03:05 kepford