You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Roger Whitcomb (JIRA)" <ji...@apache.org> on 2014/11/04 21:44:34 UTC

[jira] [Commented] (PIVOT-960) Implement simple macro system in JSONSerializer

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

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

Okay, in looking at the code trying to change the macro expansion from $(NAME) to just $NAME I see a couple of problems:
1. Suppose I have a macro like:
#define PREFIX vertical
and I want to use it like this:
$(PREFIX)Alignment : 'center'
I cannot do this with just the $PREFIXAlignment syntax...
2. Even though "$" is not a valid JSON character by itself, it might be found inside some text strings, which could cause confusion in a case like this:
'Enter price as $123'
where the $123 should not be interpreted as a macro (the intention in this text), but is with this syntax.
The $(NAME) is not something that would be normal in text, and so is much less likely to be wrongly interpreted as a macro expansion.

So, I think (even though it is more verbose) that I will stick to the $(NAME) syntax.

Thoughts?  Thanks.

> 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)