I originally posted this issue in the token_filter queue here: #1558792: String type variables being wrapped with <pre></pre> tags when displayed with tokens
Dave Reid pointed me in the right direction and I confirmed that this problem appears when using variable-7.x-1.2. It does not exist in variable-7.x-1.1.
Variables defined as strings, like [variable:site_name], are being wrapped with <pre></pre> tags when they are displayed with tokens in blocks and content areas. Variables defined as text, like [variable:site_slogan], display without the <pre></pre> wrappers. The only filter I have enabled for the text format in use is the token filter. Is there a way to prevent this from happening?
Comments
Comment #1
bforchhammer commentedLooks like the
stringvariable type is missing aformat callback, and therefore falls back tovariable_format_unknown(which wraps content into pre tags). For thetexttype, the callback is set asvariable_format_text...You can implement hook_variable_info_alter() to set the format callback for the
site_namevariable; I'm not sure whether this should be changed globally for all 'string' types...Comment #2
cameron prince commentedThanks for the info, but I would argue that this should be changed globally because: 1) This is new behavior that breaks the upgrade path for some users, 2) Formatting should be left to other functions based on the needs of the programmer, 3) Inconsistent display of variable values in the UI.
For now, I've reverted to v7.x-1.1.
Comment #3
jose reyero commentedAdded better formatting for both 'text' and 'string' types. Both can have an 'allowed tags' property. If empty, the first will default to filter_xss_admin, the second to check_plain.