Commit graph

176 commits

Author SHA1 Message Date
Chris Wong
0d4276220d
Update slash error message to point to () 2021-11-07 12:31:46 +00:00
Chris Wong
dc6c88fae3
Disallow slashes (/) in void elements ()
# Overview

The following syntax will no longer work:

```rust
html! {
    br /
    link rel="stylesheet" href="styles.css" /
}
```

This should be changed to the following:

```rust
html! {
    br;
    link rel="stylesheet" href="styles.css";
}
```

# Rationale

The `;` syntax was introduced in ; the rationale for it can be found there.

Removing support for the older `/` syntax will simplify the API surface, and allow for the space to be used for other things.
2021-11-07 23:17:15 +11:00
Chris Wong
317bf9e5ec
Rename Attribute to NamedAttr () 2021-11-07 11:39:44 +00:00
Alexandre Macabies
2909e5129c
Add support for Option<T> attributes ()
* Add support for Option<T> attributes

Introduces the `attr=[value]` syntax that assumes `value` is an
`Option<T>`. Renders `attr="value"` for `Some(value)` and entirely
omits the attribute for `None`.

Implements and therefore closes .

* Call `Generator::splice` directly

* Handle struct literals (edge case)

Co-authored-by: Chris Wong <xbuns@google.com>
2021-10-29 16:24:34 +11:00
Emilio González
4b317956fa
Report error for missing closing tag token () 2021-09-18 19:30:13 +10:00
Chris Wong
8990049101
Improve error message for non-string literals ()
Closes 
2021-03-21 22:20:37 +11:00
Chris Wong
ce6458af41 Fix doc comments on parser 2021-03-13 20:49:05 +11:00
Chris Wong
9f7331f427
Remove Attrs type alias () 2021-03-13 20:25:56 +11:00
Chris Wong
b8872d4098
Don't call the user a "silly bumpkin" () 2021-01-09 18:51:05 +13:00
Chris Wong
d5dec51c3a
Make the ? suffix for empty attributes optional () 2020-11-11 16:47:23 +13:00
Chris Wong
50a7e9ce37 Format everything! 2020-09-27 21:36:27 +10:00
CreepySkeleton
4d3d057cc2 Move to trybuild 2020-08-31 11:57:57 +03:00
CreepySkeleton
3e23e0d784 Turn the warning into a hard error 2020-08-31 11:57:57 +03:00
CreepySkeleton
7b06af4369 Fix cargo clippy lints 2020-08-31 11:57:56 +03:00
CreepySkeleton
7d16af9a06 Make use of SpanRange instead of Span 2020-08-31 11:57:55 +03:00
CreepySkeleton
ef120ab2d0 Transfer codebase from ParseResult to abort! 2020-08-30 23:28:49 +03:00
Chris Wong
d0f29ae410 Change username from lfairy to lambda-fairy 2019-09-14 13:48:59 +12:00
Malthe Borch
e302ba57e0 Use syn instead of literalext () 2019-05-18 15:44:43 +12:00
Thomas Lovegrove
f3a4c298de Add implicit div class/id shorthand ()
* Add implicit div class/id shorthand

* Add newline

* Add short explanation and example of implicit div
2019-04-20 13:39:24 +12:00
Chris Wong
39f543c819 Rust 2018 2019-03-16 20:18:58 +13:00
Isaac van Bakel
485ee13afb Corrected formatting on keyword element warning
The formatting argument is now only passed once.
2018-10-14 12:10:24 +01:00
Isaac van Bakel
5a74dd0232 Added warning when elements have keyword names
Fixes .
To avoid erroneously preventing elements which are actually meant to be
called `if` from being used, this is only a warning, with a suggestion
of the template syntax.
2018-10-11 22:05:47 +01:00
Chris Wong
e273d897cf Parse arbitrary expressions in classes and IDs
Closes 
2018-08-13 16:15:58 -07:00
Chris Wong
8d8d5960a5 Extend AST to allow arbitrary exprs in classes and IDs 2018-08-13 15:44:04 -07:00
Chris Wong
d8d5af97f8 Span the whole class or ID in duplicate attribute errors 2018-08-12 14:12:59 +12:00
Chris Wong
5aa0f85ec1 Show errors for a duplicate attribute in source order
* Also disallow multiple IDs
2018-08-12 14:07:31 +12:00
Chris Wong
ff5c0e769f Tweak duplicate attribute diagnostic () 2018-07-29 21:44:50 +12:00
Tom Pridham
8aa7810dfc Disallow dupe attrs () 2018-07-29 21:21:57 +12:00
Chris Wong
392279e97c Fix Clippy warning 2018-06-26 19:49:28 +12:00
Chris Wong
a1a0aa0200 Allow omitting the comma on the last match arm 2018-06-22 21:31:08 +12:00
Chris Wong
12282093eb Use diagnostic API everywhere 2018-06-22 21:28:35 +12:00
Chris Wong
41aea5f92c Require braces around element bodies 2018-06-16 21:46:28 +12:00
Chris Wong
4b25728efe Add at_span to Let 2018-06-16 20:59:41 +12:00
Chris Wong
0ceb271a50 Add outer_span property to Splice 2018-06-16 20:55:42 +12:00
Chris Wong
bfa15a0081 Rename Block.span to Block.outer_span 2018-06-16 20:49:46 +12:00
Chris Wong
9d56ba0bcb Keep spans for semicolons; change element body to a block 2018-06-09 20:51:34 +12:00
Chris Wong
9763541ca7 Keep the span of the leading @ symbol 2018-06-09 17:59:24 +12:00
Chris Wong
254ac54103 Merge If and Special variants 2018-05-29 19:18:30 +12:00
Chris Wong
2455de589c Update to rustc 1.27.0-nightly (2f2a11dfc 2018-05-16) 2018-05-17 20:55:29 +12:00
Chris Wong
9d90e94c87
Change macro internals to use an explicit AST () 2018-05-17 20:38:44 +12:00
Chris Wong
dd9d892b8d Fix up some minor issues 2018-04-16 20:29:32 +12:00
Coleman McFarland
2d6558c769 Use FromIterator<_> for TokenStream
Also remove conservative_impl_trait feature flag, as this is now a
stable feature.

Refs 
2018-04-16 00:54:32 -07:00
Coleman McFarland
0f453a5568 Refactor to keep up with changes to proc_macro
Instead of a `kind` field containting a `TokenNode` variant, a
TokenTree is now an enum with variants of different types (Literal, Op,
Term, etc). Note that a TokenTree could be a sequence of TokenTrees if it is a
Group variant.

Other notes:

I'm unsure about the set_span call in Builder::emit_if, but I did not want to
throw away the passed in Span.

Parsing relies on destructuring references to the values associated with
TokenTree enum variants

It doesn't seem as easy to compose/chain TokenStreams as it is to
collect a Vec<TokenTree> into a TokenStream. There is probably some
iterator API I could use instead. See `match_arms` and build.rs

Refs 
2018-04-12 14:19:26 -07:00
Chris Wong
cc833dd624 Update to rustc 1.23.0-nightly (6160040d8 2017-11-18) 2017-11-19 19:55:11 +13:00
Chris Wong
9674865846 Combine .push_str() calls across blocks
This also disallows `@let` in non-block contexts, e.g.

    img src=@let foo = bar; ;

This yields a 20 - 50 ns speedup in benchmarks, as well as reducing code
size by a slight amount.
2017-10-07 14:17:38 +13:00
Chris Wong
5cd51481c9 Rename Renderer to Builder 2017-08-12 17:41:54 +12:00
Chris Wong
a902c97091 Allow braces in toggled classes 2017-08-12 16:50:54 +12:00
Chris Wong
9487dbc3a7 Move some code around 2017-08-12 16:21:13 +12:00
Chris Wong
1785071f1b Allow terminating void elements with semicolons (;)
When Rust and HTML syntax differ, Maud tends to side with Rust syntax.
This can be seen with string literals, for example, where we use
backslash escapes instead of HTML entities. Using `;` to terminate void
elements is consistent with this idea.

Moreover, this reduces confusion around the generated code. Maud does
not insert an extra slash into the HTML output (as per the spec) but
the syntax may imply otherwise.

This confusion may have been the cause of a [bug I found in the
wild][1], where the code omitted the trailing slash on an `input`
element. I suspect that this is because the author thought that a
trailing slash in the Maud template would lead to one in the HTML
output. Switching to semicolons would prevent this misconception.

[1]: https://github.com/anowell/quasar/pull/3
2017-08-04 20:58:02 +12:00
Chris Wong
21d19adb13 Add some more comments 2017-07-31 22:25:00 +12:00