Theme Conditional - Target Xth Post
-
You can use helpers to make more complicated conditionals. For example:
In your plugin (or theme's library.js):
helpers.appendAdIfSecondPost = function(post) { return parseInt(post.index, 10) === 2 ? '<strong>Here be an ad</strong>' : ''; };
In your template:
{function.appendAdIfSecondPost}
Here's an old thread explaining how to add helpers to your plugin: https://community.nodebb.org/topic/3554/how-to-create-and-use-a-template-helper
-
the idea of the templating engine is to keep really complex stuff away from the HTML markup. Otherwise you can have really complicated looking HTML, while it really should just be a JS script.
Copyright © 2024 NodeBB | Contributors