These are chat archives for canjs/canjs

26th
Oct 2015
Ilya Fadeev
@ilyavf
Oct 26 2015 14:50
can.stache("{{name}}").({name: "Name"}) returns a document fragment. How can I get a string value of it?
Justin Meyer
@justinbmeyer
Oct 26 2015 14:53
why do you need a string?
Ilya Fadeev
@ilyavf
Oct 26 2015 14:54
to use stache with other libraries (e.g. d3)
basically, i want to pass to my component that uses d3 a template that d3 will render its way.
Justin Meyer
@justinbmeyer
Oct 26 2015 14:55
@espretto I'm not sure what you mean exactly by "attr's is a computed property implemented within the child component. it seems the child overriddes the parent's possibly stubbed/non-existant implementation."
Matthew Phillips
@matthewp
Oct 26 2015 14:55
insert the fragment into a div and use div.innerHTML
Justin Meyer
@justinbmeyer
Oct 26 2015 14:55
@ilyavf why do you need a string?
Ilya Fadeev
@ilyavf
Oct 26 2015 14:55
@justinbmeyer to use stache with other libraries (e.g. d3: basically, i want to pass to my component that uses d3 a template that d3 will render its way)
@matthewp thanks. Is this the only way?
Matthew Phillips
@matthewp
Oct 26 2015 14:57
easiest way i can think of
Justin Meyer
@justinbmeyer
Oct 26 2015 14:58
stache is totally fragment based
the only other thing I can think of would be to somehow make stache only use Text sections
which might be possible ...
Matthew Phillips
@matthewp
Oct 26 2015 15:00
I don't see anything wrong with appending the fragment and then getting the innerHTML
Justin Meyer
@justinbmeyer
Oct 26 2015 15:00
really slow
unnecessarily slow
Ilya Fadeev
@ilyavf
Oct 26 2015 15:00
and ugly :) $('<div></div>').html(tpl({name: 123}))[0].innerHTML
Justin Meyer
@justinbmeyer
Oct 26 2015 15:00
I don't think stache is probably what you want
Matthew Phillips
@matthewp
Oct 26 2015 15:00
you can hide the ugliness in a module
Justin Meyer
@justinbmeyer
Oct 26 2015 15:01
lodash has templates right?
Matthew Phillips
@matthewp
Oct 26 2015 15:01
so it's just stacheToString(template())
Justin Meyer
@justinbmeyer
Oct 26 2015 15:01
still ... I think this is the wrong tool
stache has live binding
stache parses HTML
none of that @ilyavf needs
if it were me ... I'd use lodash templates
Ilya Fadeev
@ilyavf
Oct 26 2015 15:01
yeah, but if already have stache in the project, and this is a new requirement... I dont want to add another templating library...
Justin Meyer
@justinbmeyer
Oct 26 2015 15:01
and the system-text plugin
do you have lodash already?
there are 100 byte template libraries
(maybe 200)
but very small template libraries
I'd use system-text and a micro template library
it will be much faster ... and less hacky
alternatively ... you could make stache change var section = new HTMLSectionBuilder(), to:
var section = new TextSectionBuilder(),
and see if that can be made to work
Ilya Fadeev
@ilyavf
Oct 26 2015 15:05
lodash would work, good idea. But still, i want to use only one template lib.
Let me check the "section" thing...
Justin Meyer
@justinbmeyer
Oct 26 2015 22:20
@/all DoneJS release article preview: http://blog.bitovi.com/?p=1946&preview=1&_ppp=20859669cd let me know what you think. Please don't tweet or post.