#imported macro causes error if it calls a macro as a string?

rayschwartz's Avatar

rayschwartz

12 Feb, 2014 08:02 PM

I'm importing a group of macros like this:

#import('/Site Name/formats/getCamelCaseTitle')

If the contents of getCamelCaseTitle is:

#macro (getTitle $n)
#if ($n.getChild('title'))
    #set ($title = $n.getChild('title'))
#else
    #set ($title = $n.getChild('display-name'))
#end
$_EscapeTool.xml($title.value)#end
#macro (camelCase $t)
#set ($t = $t.substring(0,1).toLowerCase() + $t.replace(' ', '').substring(1))
$t#end

I can #import without error. If I add the macro I actually want in getCamelCaseTitle:

#macro (getCamelCaseTitle, $n)
#camelCase("#getTitle($n)")
#end

submitting getCamelCaseTitle causes no error, but, I get this error from the page using the #import statement when it is edited and submitted (it would be nicer to see this error in view mode):
Velocity content invalid: Parser Error: null

This version of macro getCamelCaseTitle works fine (note no quotes):

#macro (getCamelCaseTitle, $n)
#getTitle($n)
#end

This version does not:

#macro (getCamelCaseTitle, $n)
#set ($t = "#getTitle($n)")
#end

Is there anything I can do syntactically or structurally that can make this work?
Otherwise I'll need to repeat the macros that can't be #imported which would be disappointing since that was the reason for adding #import — so you wouldn't have to repeat macros.
Thanks for your help.

  1. 1 Posted by Ryan Griffith on 12 Feb, 2014 09:27 PM

    Ryan Griffith's Avatar

    Hi,

    Based on your description, it sounds like you are running into this known defect in which submitting a Format that imports another Format that contains a macro that calls another macro within a string throws a Parse Error: null error message.

    Feel free to use this link to track the progress of this issue or keep an eye out for it on our Release Notes site.

    Unfortunately, the only workaround would be what you mentioned until the issue is resolved. The good news; however, is that we believe we may have narrowed down a possible solution to the issue.

    Please let me know if you have any questions.

    Thanks!

  2. Ryan Griffith closed this discussion on 18 Feb, 2014 01:25 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac