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

Allow much more in parentehsis expressions. #27

Merged
merged 5 commits into from
Jun 24, 2018
Merged

Conversation

kaj
Copy link
Owner

@kaj kaj commented Jun 23, 2018

Basically, just handle nesting parenthesis, comments, and strings, and let the rust compiler sort everything else out in the generated code.

Attempts to implement @kornelski s suggestion from #25 .

kaj added 2 commits June 23, 2018 20:16
Basically, just handle nesting parenthesis, comments, and strings, and
let the rust compiler sort everything else out in the generated code.

Attempts to handle #25 .
Also, allocate slightly fewer strings.
@kaj
Copy link
Owner Author

kaj commented Jun 23, 2018

Ok, now pretty much anything goes inside a parentheis (or brackets) in an expression. But it is probably a bit too flexible at the moment. I'm happy about the following things being permitted expressions (which I think they are now).

  • @foo
  • @(foo)
  • @foo(args)
  • @foo[index]
  • @( ... some complex expression ...)

But I'm not so sure about:

  • @&( ... some complex expression ...)(args)[index]

... and other complex variants ...

kaj added 3 commits June 24, 2018 13:59
There was some stuff allowed in outer expression that should only be
allowed in parentheis, and therefor there is no need to support them
speficially.
No need to allocate all those strings.
@kaj kaj merged commit 82ff9aa into master Jun 24, 2018
@kornelski
Copy link
Contributor

82ff9aa has regressed. My templates don't compile any more:

warning: Template parse error in "/www/crates.rs/front_end/templates/home_categories.rs.html":
warning: 6: @for cat in cats {
warning: ^ Error in expression starting here:
warning: 6: @for cat in cats {
warning: ^ Error in loop block:
warning: 27: @if !cat.sub.is_empty() {
warning: ^ Error in expression starting here:
warning: 27: @if !cat.sub.is_empty() {
warning: ^ Error in conditional expression:
warning: 27: @if !cat.sub.is_empty() {
warning: ^ Expected expression
warning: 27: @if !cat.sub.is_empty() {
warning: ^ Expected rust expression
warning: 27: @if !cat.sub.is_empty() {
warning: ^ Alt

https://gitlab.com/crates.rs/front_end/blob/master/templates/home_categories.rs.html#L6

@kornelski
Copy link
Contributor

907f592 was fine.

kaj added a commit that referenced this pull request Jun 25, 2018
Fix regression introduced in #27, spotted by @kornelski .
@kaj kaj deleted the anything-in-parens branch July 2, 2018 21:48
kaj added a commit that referenced this pull request Jul 5, 2018
Changes since v0.3.16 includes:

* Template syntax:
  - Allow local ranges (i.e. `2..7`) in loop expressions.
  - Allow underscore rust names.  There is use for unused variables in
    templates, so allow names starting with underscore.
  - Issue #24 / PR #28: Allow logic operators in `@if ...` expressions.
  - Issue #25 / PR #27: Allow much more in parentehsis expressions.

* Improved examples:
  - A new design for the framework examples web page, using svg graphics.
  - Improve code and inline documentation of iron and nickel examples.
  - Add a similar example with the Gotham framework.

* Recognize `.svg` static files.
* Allocate much fewer strings when parsing expressions in templates.
* PR #26: use `write_all` rather than the `write!` macro in generated
  code, contributed by @kornelski
* Fix `application/octet-stream` MIME type.  Contributed by @kornelski.
* Use write_str/write_all when generating output.  Contributed by
  @kornelski.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants