Getting theme max width without ${theme:maximumWidth}

Getting theme max width without ${theme:maximumWidth}

This question has suggested answer(s)

Is there a widget API available for retrieving the maximum width of the theme without using the ${theme:maximumWidth} token? I would like to get the quotient after dividing this value in two for a CSS rule; however, the NVelocity engine is choking on the unexpected format of the theme token. For example:

#set($halfWidth = ${theme:maximumWidth} / 2)

...generates this error (referenced location highlighted, above):

NVelocity.Runtime.Parser.ParseException: Lexical error: NVelocity.Runtime.Parser.TokenMgrError: Lexical error at line 148, column 27. Encountered: "m" (109), after : ""

I'm guessing from the error that theme tokens are not processed until after NVelocity has finished. Is there a way to do this without hardcoding the quotient or relying on a widget configuration parameter?

All Replies
  • Add single quotes around the token like so:

    #set($halfWidth = $core_v2_widget.ApplyTokens('${theme:maximumWidth}'))

    That seems to work.  Just remember that is a string value not an int so you will need more processing on it