How do I pass a "list" argument to an Umbraco macro?
I have an Umbraco macro that I'd like to pass a "list" argument to — i.e. I have multiple elements that I'm transforming with XSLT, and I'd like to transform some of them in a "special" way.
Ideally I'd like to try something like this:
<umbraco:Macro Alias="DoStuff" runat="server">
<styleThisSpecially>NameOfElement1</styleThisSpecially>
<styleThisSpecially>NameOfElement2</styleThisSpecially>
</umbraco:Macro>
Unfortunately that doesn't seem to work — the "styleThisSpecially" elements are not recognised.
Workarounds I can think of are:
- passing through arguments like "styleThisSpecially1", "styleThisSpecially2", "styleThisSpecially3", ...
- passing through my argument as a comma separated list like "styleThisSpecially='val1,val2,val3'"
...but neither of these options seem very "neat". I tried using multiple "styleThisSpecially" attr开发者_如何学Pythonibutes on the umbraco:Macro element, but that caused an error ("the tag contains duplicate 'expandBox' attributes").
Is there a clean and tidy way to do this?
If I understand you correctly you're starting at "point X" and working out all the elements and you want to pass them all to the macro as a list. Probably a neater solution is either: 1. Let the page not only find the elements, but also iterate these and pass them one at a time to the macro for "rendering/processing/whatever" 2. Pass "point X" to the macro and let the macro work out what the elements are?
Doesn't really answer the question of whether you can pass a list of elements to a macro, but I think perhaps (certainly if you're working in XSLT) this is rarely something you'd want to do.
精彩评论