Home
The Toolkit for Online Communities
13502 Community Members, 0 members online, 2087 visitors today
Log In Register

Forum OpenACS Q&A: List builder is a mean lean html-quoting monster

OpenACS Home : Forums : OpenACS Q&A : List builder is a mean lean html-quoting monster

Icon of Envelope Request notifications

Hi Folks,

I'm playing with List Builder, and mostly loving it.

HOWEVER, I have some html code that I'm pulling out of a select that includes a <br>.  LB apparently does some quoting somewhere (still peering at its innards) so that instead of getting a <br> (yes, I want a new line in the middle of a LB element), I'm getting an &ltbr&gt.  Is there a way to disuade LB from this (probably usually useful) behavior?

I had a look at Jade's docs and the api-doc, but haven't turned anything up yet.

Thanks!

+
Posted by Vinod Kurup on
I haven't used the list-builder, but you might try looking for any calls to ad_quote_html in the list-builder procs (which are in acs-templating/tcl/list-procs.tcl.
+
Posted by Dirk Gomez on
Yes, html is now quoted by default. Two solutions:

Add a noquote tag to the variable in question which explicitly turns off quoting for this variable.

Print out the br tag on the adp page. (Preferred solution)

+
Posted by Andrei Popov on
> Print out the br tag on the adp page. (Preferred solution)

Works well only as long as this is not a user comment, isn't it?  Yet if it is -- noquote tag should not be a problem...

+
Posted by Lars Pind on
Cathy,

Use display_template like this:

template::list::create \
    -name foo \
    -multirow foo \
    -elements {
        html_elm {
            display_template {@foo.html_elm;noquote@}
        }
    }

That way, the value of the 'html_elm' column will not be quoted.

/Lars

+
Posted by Mark Aufflick on
An important extenstion to Lars' display_template example:

If you have used the display_eval parameter in your element and then try the display_template above you will be surprised to find the original value presented.

That's because the display_eval param doesn't modify the column value, it makes a new column. Extending the above example:

...
-elements {
  success_bool {
    display_eval {[ad_decode $success_bool t Success "<em>FAIL</em>"]}
    display_template {@foo.success_bool___display;noquote@}
  }
}

Note that the separator is THREE underscore characters. In a similar way if you have constructed an url with the link_url_eval param, you can access that via col_name___link_url

If you want some insight into the upvar magic of Lars and the completeness of listbuilder functionality - take a look at the source for template::list::prepare_for_rendering !

+
Posted by Lars Pind on
In this case, I'd recommend moving the 'eval' chunk into your db_multirow statement to add it as a column in the multirow, and avoid using the display_eval here. Makes things a bit cleaner.

/Lars

+
Posted by Mark Aufflick on
yes i was doing that originally.

it's debateable which is less clean: setting html code in a database result set versus exploiting the innards of listbuilder

i suspect your way will confuse less people - also saves a hairy uplevel i cooked up to access vars from the page...