Forum OpenACS Development: How can I use <include> in a theme's form template

Dear all,

I am developing an OpenACS theme. In order to provide a themed style for forms, I am customizing the file /openacs-my-theme/resources/forms/my-form.adp. I can use this style as default style for all forms on the site.

In order to reduce redundant code within this template, I wanted to use the tag inside. This, however, fails with the error message:

can't read "__adp_stub": no such variable
    while executing
"template::util::url_to_file "my-form-error-include" "$__adp_stub""

Is this a bug? Any ideas for workarounds?

Collapse
Posted by Gustaf Neumann on
The form and list templates can be quite complex, since these are parsed twice (see the various <noparse> statements in the standard templates). Probably, you can tweak your code with appropriate <noparse> statements.

The conceptual simpler approach is to use separate templates in your theme, such as e.g. used in the openacs-bootstrap3-theme:

    ...    
    openacs-bootstrap3-theme/resources/lists/table.adp   
    openacs-bootstrap3-theme/resources/forms/form-horizontal.adp   
    ...   
Since these templates are modified not too often the code duplication seems acceptable.
Collapse
Posted by Michael Aram on
Because of the not perfectly homogeneous implementation of the UI toolkit that I am trying to integrate, I have to touch/style many of the form widgets individually (e.g., some widgets require the label to come after the input, others require it to appear before, ...).

Currently, I am styling these widgets individually using adp "switch" and "if" tags within the template openacs-my-theme/resources/forms/my-form.adp. (Similarly, but much more extensively, as it happens in openacs-bootstrap3-theme/resources/forms/form-horizontal.adp.)

In my case, the duplication is not really acceptable anymore. The code would be much more readable, if I would be able to use the <include> tag there; wrapping it inside a <noparse> Tag does not help, unfortunately. Wrapping it in two nested <noparse> removes the error, but the code is not executed at all, then. It might also help, if I would be able to use a .tcl file  as companion to this ADP, but this is not supported either.

Collapse
Posted by Brian Fenton on
Michael, you probably already know this, and it may not even help you solve your problem, but you can include TCL code in ADP pages using the <%= ... %> syntax

Brian

Collapse
Posted by Brian Fenton on
Hi Michael

without seeing your code, it's hard to be too sure of what is happening. You definitely can use the "include" tag, and as Gustaf says, it can probably be resolved using the "noparse" tag. https://openacs.org/doc/acs-templating/tagref/noparse

Brian