envone / ember-runner

EmberJS preview and build tool for Node.JS
MIT License
50 stars 6 forks source link

how to add handlebars.js? #37

Open SamuelTilly opened 12 years ago

SamuelTilly commented 12 years ago

http://emberjs.com/blog/2012/08/03/ember-1-0-prerelease/

"Handlebars is no longer bundled with Ember."

Am i supose to download the latest from http://handlebarsjs.com/ and add it to ember_runner_config.json somehow?

envone commented 12 years ago

Hi @eldamar sorry for the long response, I sick from saturday, the way I do is by adding directly in the html <script>, here is how I do, by creating an index.html in apps/admin/static/index.html (where admin is your app).


<html>
  <head>

    <link rel="stylesheet" href="/libraries/shared.css" type="text/css" media="screen" charset="utf-8" />
    <link rel="stylesheet" href="admin.css" type="text/css" media="screen" charset="utf-8" />

    <title>Admin</title>
  </head>

  <body></body>

  <script type="text/javascript" src="/libraries/jquery.js"></script>
  <script type="text/javascript" src="/assets/handlebars-1.0.0.beta.6.js"></script>  
  <script type="text/javascript" src="/libraries/ember.js"></script>
  <script type="text/javascript" src="admin_templates.js"></script>
  <script type="text/javascript" src="admin.js"></script>
</html>

And put the handlebar library file in public/assets (or the folder you like inside public)

Hope this help,

paynerc commented 12 years ago

Why would you do this differently than how you do ember and have it install in the libraries folder? If you are already going to the point of including ember as a submodule and using the submodule functionality to chose the version of ember you want, why not do the similar thing for handlebars?

envone commented 12 years ago

Well, good point, I think that somewhere in the past I have made this step, by adding vendors/handlebars/lib/handlebars_version_x_x.js and a main.js that point to that file, you can do it perfectly. And you can do the same think with jquery as I do, I have created to join jquery with jquery-mousewheel in one.

And for the submodules thing, the idea is to have other frameworks that ember.js that can be shared, I have a couple of frameworks that are shared among my apps, this is the main idea of the ember-runner, to allow us manage many frameworks and many apps as we like (other than emberjs).

Maybe for next step when we create generators, we can generate automatically the structure folder and add embers and handlebars inside vendors...

SamuelTilly commented 12 years ago

Thanks for the information i was wondering how static folder was meant to be used, makes so much sense to me now. If i add a custom vendor do i need to supply a package.json file as well?

Hmm, trying this out. I have vendors/handlebars/lib/ with main.js and handlebar-1.0.0.beta.6.js and in main.js i have set require("handlebars/handlebar-1.0.0.beta.6"); but it wont load the handlebar files. what am i missing?

I tried changing the handlebar-1.0.0.beta.6 to handlebar.js and just require("handlebars/handlebars"); and that works.

I get an error saying "Uncaught ReferenceError: Handlebars is not defined" though, i think it's because all the generated js will have something like this:

(function(exports) { content of require 1 
})({});
(function(exports) { content of require 2 
})({});
(function(exports) { 

})({});

Were the last "export" function is the file that requires the first two files. Isn't this a bit of wierd output(?)