diff --git a/examples/partials/template2.hbs b/examples/partials/template2.hbs index 934416eb7..60255888b 100644 --- a/examples/partials/template2.hbs +++ b/examples/partials/template2.hbs @@ -1,4 +1,4 @@ {{#*inline "page"}}
Rendered in partial, parent is {{parent}}
{{/inline}} -{{> (lookup this "parent")}} +{{> (lookup . "parent")}} diff --git a/src/grammar.pest b/src/grammar.pest index 6ed45e53f..6e5f3faee 100644 --- a/src/grammar.pest +++ b/src/grammar.pest @@ -32,7 +32,7 @@ path_char = _{ "/" } identifier = @{ symbol_char+ } partial_identifier = @{ partial_symbol_char+ | ("[" ~ ANY+ ~ "]") | ("'" ~ (!"'" ~ ("\\'" | ANY))+ ~ "'") } -reference = ${ path_inline } +reference = { path_inline } name = _{ subexpression | reference } @@ -40,7 +40,7 @@ param = { !(keywords ~ !symbol_char) ~ (literal | reference | subexpression) } hash = { identifier ~ "=" ~ param } block_param = { "as" ~ "|" ~ identifier ~ identifier? ~ "|"} exp_line = _{ identifier ~ (hash|param)* ~ block_param?} -partial_exp_line = _{ ((partial_identifier|name) ~ (hash|param)*) } +partial_exp_line = _{ (partial_identifier|name) ~ (hash|param)* } subexpression = { "(" ~ ((identifier ~ (hash|param)+) | reference) ~ ")" } @@ -127,8 +127,9 @@ path_sep = _{ "/" | "." } path_up = { ".." } path_key = _{ "[" ~ path_raw_id ~ "]" } path_root = { "@root" } -path_current = _{ "this" ~ path_sep | "./" } +path_current = @{ ("this" ~ path_sep) | "./" } path_item = _{ path_id|path_key } path_local = { "@" } +path_current_standalone = _{ "." } path_inline = ${ path_current? ~ (path_root ~ path_sep)? ~ path_local? ~ (path_up ~ path_sep)* ~ path_item ~ (path_sep ~ path_item)* } -path = _{ path_inline ~ EOI } +path = _{ (path_inline ~ EOI) | (path_current_standalone ~ EOI) } diff --git a/src/grammar.rs b/src/grammar.rs index 6be52a6cc..2b0bb6e6a 100644 --- a/src/grammar.rs +++ b/src/grammar.rs @@ -85,6 +85,8 @@ mod test { "[$id]", "$id", "this.[null]", + ".", + "this", ]; for i in s.iter() { assert_rule!(Rule::reference, i); @@ -183,6 +185,7 @@ mod test { "{{exp key=(sub)}}", "{{exp key=(sub 0)}}", "{{exp key=(sub 0 key=1)}}", + "{{exp .}}", ]; for i in s.iter() { assert_rule!(Rule::expression, i); @@ -306,6 +309,8 @@ mod test { "[foo]", "@root/a/b", "nullable", + ".", + "this", ]; for i in s.iter() { assert_rule_match!(Rule::path, i);