[ 
https://issues.apache.org/jira/browse/PIVOT-960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14190401#comment-14190401
 ] 

Roger Whitcomb commented on PIVOT-960:
--------------------------------------

I can definitely change the macro expansion format to $NAME instead of $(NAME). 
 I had thought of ${NAME} (which is the syntax Ant uses).

To answer your questions:
* If a variable is not defined, then then macro remains unexpanded, so $NAME -> 
$NAME still. This is why I chose $NAME as the expansion, because "$" is not 
otherwise used specially in JSON.
* Currently there are no (additional) exceptions possible in this code than 
there used to be, so no worries there.

A couple of other points:
* The macro value starts at the first non-white character after the name, and 
can be continued on another line using \ as the last character on the line.
* The macro name is just bounded by whitespace, so the "name" can be any 
combination of non-white characters (such as {_(IOP)_} if you want).... 

So, will commit the change with the $(NAME) -> $NAME change as suggested.


> Implement simple macro system in JSONSerializer
> -----------------------------------------------
>
>                 Key: PIVOT-960
>                 URL: https://issues.apache.org/jira/browse/PIVOT-960
>             Project: Pivot
>          Issue Type: Improvement
>          Components: core-json
>    Affects Versions: 2.0.4
>         Environment: All
>            Reporter: Roger Whitcomb
>            Assignee: Roger Whitcomb
>            Priority: Minor
>             Fix For: 2.1
>
>         Attachments: 960.patch
>
>
> It occurred to me since we are using JSON style sheets to style our 
> application, and it is getting quite big, that a macro system (maybe similar 
> to C/C++ with #define or something similar) would be useful, especially for 
> repeated colors, and other constants (like padding values, fonts, etc.)  This 
> would enable using custom values consistently while avoiding inconsistencies 
> due to typos or changes introduced one place and not others.
> I was thinking of a simple
> #define NAME value
> as in C/C++, and then using $(NAME) as the substitution token.  This is 
> easily implemented in JSONSerializer.
> I'm open to suggestions for the syntax, but I believe the feature will be 
> very useful, especially for the JSON stylesheet.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to