I am missing a `bootstrap` method for non-angular apps
I think my use case is not that exotic: I just need to preparse my
ons-templates to have some placeholders replaced on them (specifically, I am talking about i18n strings). I am not using Angular, so that the
bootstrapglobal function is not available.
I include onsenui.js as a normal file so that I don’t have a way to put it “in pause”, load my strings (via an ajax call), change the templates and then let it do its job as usual, using the now “translated” templates.
I also tried loading onsenui (beta 5) via
require()but it apparently doesn’t work. I get some weird “jsmutationobserver” error. I am using webpack and not browserify, so maybe that’s the problem.
Anyway, I understand that this not a simple problem to solve, since by default onsenui bootstrap itself automatically and changing this default is not possible of course.
Maybe, adding a class to the
bodyor an attribute to the
Thanks for listening
P.S.: my current solution is to compile those strings on-the-fly on the
initevent of the navigator (so, each time I am about to show a page). I still have problem bootstrapping, because of the asynchronous ajax call to fetch the language file but I can deal with it.
ons.bootstrapis just a synonym of
angular.module('myApp'), so of course there is no need to use it in Onsen 2.0 core.
About your issue, I guess you can start your navigator without pages (i.e remove
pageattribute) and do
resetToPagewhenever your first template is ready. This looks like a very simple solution so perhaps I’m missing something about your problem.
By the way, I’d recommend you to update to the latest beta. Many things have changed since beta.5.
You’re right. I forgot that I had the
pageattribute on the navigator
This only solves part of the problem though, because once the
ons.readyis fired, my
ons-templates in the DOM are empty, like they have been “consumed” (and it’s OK, I guess ONS stores them in memory, out of the DOM). So it’s too late for me to replace the strings inside them.
I guess I will stick with changing the strings on each page’s
initevent handler. No big deal.
(I’ll update to the latest beta right now)
ons-templateremoves its content and stores it in an internal variable to avoid ID collision and other stuff. I think you would prefer to use
pageHTMLparameter instead of the normal
pageone. That way you don’t need to modify the templates. In case you really want to use
ons-templateand modify it, the variable where the content is stored is called
template(original, I know).