rtml
description
(r)ust macros for h(tml) expansion => rtml but also (r)ust type safe (css) => rcss
usage
the output html will be in non pretty form.
Page Title
text
This is a Heading
This is a paragraph.
When there are attributes, they go first, before adding any inner nested html.
div!
call render()
when the html needs to be built.
Getting Started
Install the latest version of the rtml crate into your project
use either specific tags you plan to use or reference all tags by adding this use
statement.
use p;
// or
use *;
CSS
Rtml also supports type safe css.
The major difference between real inline css and rcss is that values are in strings. type safe values are not yet supported. Another difference is that properties are split on commas ,
instead of semicolons ;
Attribute selectors, Pseudo-classes, Pseudo-elements, At-rules, and functions are not yet implemented. Css Properties, Selectors, and Combinators are implemented in full.
Attributes
There are two attributes that have been changed to make parsing easier as '-' is not a valid token stream in an identifier.
html5 | rtml |
---|---|
http-equiv | http_equiv |
accept-charset | accept_charset |
Type Safe Attributes
rtml allows an additional layer of type safety with tag use. For example,
a!
My Documents
Is the correct attribute allowed on the a
tag.
If you were not familiar, you might try to use the src
attribute which is invalid. Most other website building projects would not prevent incompatible attribute use.
In rtml, there is a helpful error.
a!
My Documents
the trait bound `src: ACompat` is not satisified
the following other types implement the trait `ACompat`:
accesskey
class
contenteditable
dir
download
draggable
hidden
href
and 13 others
Breaking this error down,
the trait bound src: ACompat...
src
: is the name of the attribute attempting to be usedACompat
: is the trait that would need to be implemented, every tag has their own version. Such asDivCompat
andStyleCompat
accesskey class contenteditable
: are a few of the attributes supported, Rust lists them in alphabetical order and therefore will not show all
Components
not implemented yet