Skip to content

Array elements not equal citizens #200

Closed
rragan opened this Issue Nov 30, 2012 · 7 comments

3 participants

@rragan
rragan commented Nov 30, 2012

{?data.list[1]} xxx {/data.list}
is not liked by the compiler.

Shouldn't array elements be equal citizens to scalars in most all usages?

@vybs
vybs commented Nov 30, 2012

possible, again all extensions to the compiler.

too many ways to the same thing can be good and bad

@rragan
@jairodemorais

@rragan Sorry for the delay, I didn't see this issue. I found another solution.
Maybe you could do this:

Template:

{?data.list[1]} xxx {/data.list[1]}

Context:

{ "data" : { "list" : ["hi", "bye"] } }

Output:
xxx

@rragan
rragan commented Feb 26, 2013

OMG, that works. Seems fine but now I am starting to feel that the closing syntax matching the opening one is getting out of hand. Maybe it is time to revisit {/} for closing the matching open tag. Folks could write the full matching path for documentation/surety if they wanted.

@jairodemorais

@rragan we have only one condition in the section tag:

section "section"
  = t:sec_tag_start ws* rd b:body e:bodies n:end_tag &{ return t[1].text === n.text;}

As you can see "t[1]" (represents the open tag text) must be equal to "n" (represents the end tag text). It would be really easy to change. but should we?

@rragan
rragan commented Feb 26, 2013

I think it is worth serious consideration. When I see things like:

{data.people.primaryUser.firstName}
...
{/data.people.primaryUser.firstName}

I feel like we are making users write too much. I might use explicit matching close tags in deeply nested areas for my own sanity but for deeply pathed references, I'm sure lots of folks would opt for a simpler closng syntax. When you throw in the need to match subscripting too, it is certainly non-intuitive.

@jairodemorais

@rragan could you create a new ticket suggesting the simple closing syntax.

I think this ticket should be closed now. Because it is not a bug :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.