How to call javascript functions
-
That did it, thanks Baris!
-
@trevor may I ask how exactly are you injecting your code? or in another word, where? which file are you editing,
header|footer.tpl
?I'd like to do so in a cleaner way, and since it's custom code, how to safely keep the file in the NodeBB dir without risking loosing it or being overwritten when you update? can i use the
/public/
dir for custom assets?I did something similar using a plugin is to use the
filter:footer.build
hook, and inject script tag in there, without the need to modify any NodeBB native code.plugin.json
"hooks": [ { "hook": "filter:footer.build", "method": "footer", "callbacked": true } ]
plugin.js
.... Plugin.footer = function(custom_footer, callback) { custom_footer = custom_footer + ''; custom_footer += '<script src="path/to/script/god.js"></script>'; callback(null, custom_footer); } ...
Also, as far as I know, generally, NBB plugins execute on the server, (unless they inject them selves into content, which is kinda what i did) and not on the client, it seems as your code is client side.
-
I think @trevor is modifying the templates and js files as is. So everytime we make a major upgrade he has to go through the pain of manually upgrading his files by hand.
Part of my long term goal here is to find some sort of solution to being able to customize templates and functionality without being totally screwed everytime we overhaul a template or client side JS.
I'm open to solutions... but I have an idea. I'm hoping to be able to implement something solid before we hit 0.3.x.
-
@psychobunny ahh ... I am not sure I want to do that.. it would be nice if we can override some templates, or augment them, maybe in the
nodebb-themes
and while you're there, i feel like template.js can be abstracted (just like the awesome work @baris did for DBs) to use a templating engine of choice,
handlebars || jade || ejs
, no offense, I like your dcp.template, but it's too light, lol, or just add an<!-- ELSE -->
inverse block, pl0x -
there is an else conditional, see
topics.tpl:27,
account.tpl:38,
category.tpl:67,
etc.that said, I agree with you, as I think I said on the dcp.templates issue thread there should be a way to abstract out template parsing to allow various engines
-
inb4
-
he only said this because I threatened him on skype
-
hahaha
I judged dcp.template too quick, i could swear I Ctrl+F in templates.js and didn't see an ELSE, so I gave up thenYea, I know we talked about this before, that just was my friendly reminder, didn't mean to start a skype-war
-
yeah haha. I don't know, I guess templates.js was an adventurous thought of being able to import themes from old school forums.
Now that I think about it, probably bit off more than we could chew. So yeah definitely open to some sort of abstraction, although I don't imagine that will seriously happen until a lot of interest comes up in the realm of theming NBB
As for skype wars? this happens everyday, all the time. the winner is usually the one that posts the most convincing meme