Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create StringTemplate 4 examples / getting started documentation #15

Open
sharwell opened this issue May 13, 2013 · 3 comments
Open

Create StringTemplate 4 examples / getting started documentation #15

sharwell opened this issue May 13, 2013 · 3 comments
Milestone

Comments

@sharwell
Copy link
Member

No description provided.

@ghost ghost assigned sharwell May 13, 2013
@st4l
Copy link

st4l commented May 27, 2013

Sam, what's the lookup list for attribute properties? I'm having issues trying to render

var dict = Dictionary<string, MyType>;

Tried passing dict.Values to a template and it doesn't find any objects, passing dict renders the Keys collection.

@st4l
Copy link

st4l commented May 27, 2013

More details.

table(relation) ::= <<
CREATE TABLE <relation.Name>
 <relation.Columns.Values:col()>
>>
col(col) ::= <<
   column <col.Name> 
>>

When I look at this in visualizer, I'm guessing it resolves relation.Columns first, which is the Dictionary<string,Column>, and it enumerates the Keys collection. When it tries to resolve .Values it doesn't find it because it has the enumeration results, not the actual object.

@st4l
Copy link

st4l commented May 27, 2013

And... bingo
Not intuitive, and hadn't found anything in the documentation about this:

       if (property == null)
                value = map[TemplateGroup.DefaultKey];
            else if (property.Equals("keys"))
                value = map.Keys;
            else if (property.Equals("values"))

(in Antlr4.StringTemplate\Misc\MapModelAdaptor.cs)

The adapter expects '.keys' or '.values' in lower-case. You could either change the capitalization there (to align it with c#/.NET conventions) or write a note in the documentation about the case for those properties. I tested it and it works for <rel.Columns.values:col()>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants