Widgets, braces, and Benchpress
-
So I'm returning to this topic because for higher level widget integrations, a solution to this would be helpful going forward.
As a recap, there was issue with complex widgets, because code braces {} are interpreted by benchpress and replaced (as it uses those too for its codes.)
It affected complex widgets with API calls and if statements etc.- does widget code need to go through the benchpress parser?
- this may need a benchpress adjustment, but is there a way this problem can be got round, without rewriting widgets to avoid using {} in certain places?
This may be only answerable by @baris.
I do get that currently this wont affect most forum admins, but as features progress it may become more important.
A forum Im working with has some amazing features under development, but at present the js code cant work without a rewrite, to avoid the benchpress {} conflict. -
The reason it is parsed by benchpress is because it allows us to access the data used to render the page in the widget. Anything that's in
ajaxify.data
can be used by the html widget to render custom html.If you don't want to change your javascript to you can put them in custom JS tab and target your widgets. The custom JS tab doesn't have the
{}
issue. -
@baris Just for clarification:
as category.tpl widget allows you to specify which categories to run the widget in (by typing category number in the box in the setup).
If I call the function thats in custom js, from the widget html,
will I even need to check which category with that ajaxify code, as it will only be called from those categories anyway?Edit: answered my own question by trying it. Seems you cant call functions defined in CustomJS, from the widget.
So I will do it the ajaxify way, detecting category in the customJS -
Further thing.
If use customJS, I also need custom HTML to set up the canvas.
Is there a similar command I can put in the custom HTML to only make the canvas when in the category I need?
Obviously I cant use that if (ajaxify. ) statement as that is JS