@baris tks u very much, now code works. 🙂
Let add this to the plugin docs.
Let's pretend that templates.js doesn't always perfectly manage caching of templates.
Where does it compile templates to? Could I essentially wipe the compiled templates folder and ./nodebb start again and it'd compile?
P.S. Wouldn't it be cool if ./nodebb could take a second parameter of 'clean'?
./nodebb dev clean
./nodebb start clean
Wouldn't it be magic?
Those specific commands don't exist, but they could... we run template cleaning whenever you "reload" your NodeBB.
Ah my question wasn't clear. I meant where in the filesystem. Sorry.
Didn't know 'reload' cleaned templates. Good to know. Thanks!
In that case,
@julian and it's safe to rm -rf public/templates/* ?
Should be*. The files there get regenereated every time you restart (or reload, I'd assume) NodeBB.
* Caveat Emptor
Yup. And it isn't tjs that does this, its NodeBB. We'll be moving stuff like this into grunt eventually
Gulp is cool too, but right now we have some decent amount of technical debt having built LESS compilation and JS minification into NodeBB itself as opposed to using Grunt / Gulp etc. So stay tuned to https://github.com/NodeBB/NodeBB/issues/3543 we'll be trying to cut down on this towards 1.0
What does that code actually do?
I'm trying to figure this out because I'm working on a template system myself. To me, comparing compiled templates to uncompiled ones, it looks like this compilation doesn't really do much at all. Wouldn't a better compilation system compile templates into executable functions?
Templates can be located in lots of places...
src/views for ACP, the theme itself for everything else, plugins can also introduce templates.
.compile() just collects them all and puts them (or links them) in
@julian that's way simpler than I thought the compilation was doing, although the code makes sense now (comments help with that, too )
String#replace is actually a very slow operation compared to concatenation.
Yeah its on my todo for tjs 1.0