These are chat archives for jescalan/roots

24th
Mar 2017
iljamm
@iljamm
Mar 24 2017 08:44
any thoughts guys?
Jeff Escalante
@jescalan
Mar 24 2017 12:51
I'm not sure I understand
Oh, for client templates sorry
iljamm
@iljamm
Mar 24 2017 12:52
indeed
Jeff Escalante
@jescalan
Mar 24 2017 12:52
So just pass the data from records to a script tag
Attach it to window
Then pull it from there in your client templates
And you're good
iljamm
@iljamm
Mar 24 2017 12:54
ah
thought it would be a bit more integrated
let me ask you another thing pertaining to roots client templates
Jeff Escalante
@jescalan
Mar 24 2017 12:56
Nope, separate plugins are not integrated at all. It's impossible for every plugin to be aware of the interface of every other plugin
iljamm
@iljamm
Mar 24 2017 12:56
i c
in generated client templates, in places where I have loops over locals, it has js loops building html, why not to just output a complete html instead?
Jeff Escalante
@jescalan
Mar 24 2017 13:01
Because the locals are added at runtime
So the html cannot be known without the locals being known
For example if you have a template that takes an array of posts, it cannot know how many posts are in your array before you actually pass it in. So it needs code to generate the html for whatever number it ends up being
iljamm
@iljamm
Mar 24 2017 13:04
i understand
i thought that it would be possible to completely render a template to html and then export that
iljamm
@iljamm
Mar 24 2017 13:26
i see that in the generated templates there is locals_for_with variable that is populated with data from variable locals
locals however is empty
undefined to be precise
ah, found how to pass locals into client templates
Jeff Escalante
@jescalan
Mar 24 2017 13:42
It is possible to render to html then export that, just call the function and it will put out html :)
Whenever you call it, it will render, and as you just discovered, you can pass in variables at that time
iljamm
@iljamm
Mar 24 2017 13:43
that's precisely how I am going to use it. However!
if compiled templates.js file container prerencered html, i would not need to create a number of global vars
*prerendered