# Rempl [![crates.io](https://img.shields.io/crates/v/rempl?label=latest)](https://crates.io/crates/rempl) [![Documentation](https://docs.rs/rempl/badge.svg?version=0.3.1)](https://docs.rs/rempl/0.3.1) ![MSRV](https://img.shields.io/badge/rust-1.80+-ab6000.svg) ![MPL](https://img.shields.io/crates/l/rempl.svg) [![Dependency Status](https://deps.rs/repo/sourcehut/~yuiyukihira/rempl/status.svg)](https://deps.rs/repo/sourcehut/~yuiyukihira/rempl) [![CI](https://builds.sr.ht/~yuiyukihira/rempl.svg)](https://builds.sr.ht/~yuiyukihira/rempl?) ![downloads](https://img.shields.io/crates/d/rempl.svg) ## About Rempl is a simple library that adds two macros to allow you to make functions that return html easily by embedding the html directly in your source code. No templates required! ## Installation To get started with rempl simply run ``` sh $ cargo add rempl ``` in your terminal. ## Features Rempl adds two simple macros. First, the `html!` macro which allows you to create html sections directly within your rust source. Example: ``` rust let classes = vec!["bg-red", "b-solid"]; let msg = "Hello, world"; html! {

{ msg }

} ``` As you can see, you can pass any rust expression as an HTML element attribute, or if it implments the `Display` trait, directly in the html itself. The second macro is the `component` macro, which allows you to create custom html tags, that you can call within your `html!` invocations. Example: ``` rust fn Echo(class: String, children: HtmlNode) -> HtmlTerm { html! {

{ children }

} } fn main() { let r = html! { <@Echo class="Test"> "Hello, world!" } } ``` Components can be called by using putting a `@` in front of the tag name, any attributes will be passed as parameters to the function, except for the inner html of the tag, which will be passed in the required `children` parameter. You can render your html output to a `String` by simpling calling `.to_string()` on the `HtmlTerm`. ## Features If you're running a nightly compiler, you can enable the `nightly` feature to enable some better diagnositics when writing invalid HTML. ## License This project is licensed under the Mozilla Public License which you can find [here (LICENSE)](LICENSE) or [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/).