Created
February 5, 2015 23:53
-
-
Save lampe/5bda16cf269f5d271598 to your computer and use it in GitHub Desktop.
meteor blaze notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//HTMLJS | |
HTML.Raw("<div> <p> ich bin ein paragraph </p> </div>"); | |
HTML.DIV(HTML.P("ich bin ein paragraph")); | |
HTML.DIV({'class': 'someDiv'}, HTML.P("ich bin ein paragraph")); | |
HTML.IMG({'class': 'someImg', "src": "http://i.imgur.com/UuGT4co.png"}); | |
HTML.toHTML(HTML.DIV({'class': 'someDiv'}, HTML.P("ich bin ein paragraph"))); | |
//Tracker | |
FancyReactivnes = function (value) { // much goodnes. much pretty. WoW | |
this.curValue = value; | |
this.dep = new Tracker.Dependency(); | |
}; | |
FancyReactivnes.prototype.get = function () { | |
this.dep.depend(); | |
return this.curValue; | |
}; | |
FancyReactivnes.prototype.set = function (newValue) { | |
this.curValue = newValue; | |
this.dep.changed(); | |
}; | |
//Blaze | |
Template.body.addContent((function() { | |
var view = this; | |
return Spacebars.include(view.lookupTemplate("hello2")); | |
})); | |
var div = document.createElement("DIV"); | |
document.body.appendChild(div); | |
// var RV = ReactiveVar("reactiver micha"); | |
var RV = new FancyReactivnes("Micha"); | |
var created = false, rendered = false, destroyed = false; | |
Spacebars.include(Template.body.view.lookupTemplate("hello2")); | |
tmpl = new Blaze.Template("Template.hello2", | |
function(){ | |
view = this; | |
return HTML.H1("hello2, ", Blaze.View(function() {return Spacebars.mustache(view.lookup("greeting"));})); | |
} | |
); | |
tmpl.created = function () { created = true; }; | |
tmpl.rendered = function () { rendered = true; }; | |
tmpl.destroyed = function () { destroyed = true; }; | |
tmpl.__helpers.set("greetings", function(){ return RV.get() || "meteorites" }); | |
tmpl.events({ | |
'click h1': function () { | |
// increment the counter when button is clicked | |
Session.set("counter", Session.get("counter") + 1); | |
} | |
}); | |
var renderedTmpl = Blaze.render(tmpl, div); | |
var renderedTmpl2 = Blaze.renderWithData(tmpl, {"greeting": RV.get()}}, div); | |
// renderedTmpl2.dataVar.set({greeting: "bla"}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment