sailfish/sailfish/src/lib.rs

67 lines
1.9 KiB
Rust
Raw Normal View History

2020-06-13 23:29:45 -04:00
//! Sailfish is a simple, small, and extremely fast template engine for Rust.
//! Before reading this reference,
2022-04-22 10:51:59 -04:00
//! I recommend reading [User guide](https://rust-sailfish.github.io/sailfish/).
2020-06-13 23:29:45 -04:00
//!
//! This crate contains utilities for rendering sailfish template.
//! If you want to use sailfish templates, import `sailfish-macros` crate and use
2024-03-11 17:33:11 -04:00
//! derive macro `#[derive(RenderOnce)]` or `#[derive(Render)]`.
2020-06-13 23:29:45 -04:00
//!
//! In most cases you don't need to care about the `runtime` module in this crate, but
//! if you want to render custom data inside templates, you must implement
//! [`Render`] or [`RenderOnce`] for that type.
2020-06-13 23:29:45 -04:00
//!
//! ```ignore
2024-03-11 17:33:11 -04:00
//! use sailfish::RenderOnce;
2020-06-13 23:29:45 -04:00
//!
2024-03-11 17:33:11 -04:00
//! #[derive(RenderOnce)]
2020-06-13 23:29:45 -04:00
//! #[template(path = "hello.stpl")]
//! struct HelloTemplate {
//! messages: Vec<String>
//! }
//!
//! fn main() {
//! let ctx = HelloTemplate {
//! messages: vec!["foo".to_string(), "bar".to_string()]
//! };
//!
//! println!("{}", ctx.render_once().unwrap());
//! }
//! ```
2020-06-13 13:47:20 -04:00
#![doc(
2022-02-19 00:47:00 -05:00
html_logo_url = "https://raw.githubusercontent.com/rust-sailfish/sailfish/master/resources/icon.png"
2020-06-13 13:47:20 -04:00
)]
2020-06-18 03:32:07 -04:00
#![cfg_attr(sailfish_nightly, feature(core_intrinsics))]
2020-12-17 03:06:34 -05:00
#![cfg_attr(docsrs, feature(doc_cfg))]
#![feature(const_trait_impl)]
#![feature(effects)]
#![feature(maybe_uninit_slice)]
#![feature(specialization)]
2020-12-18 05:18:52 -05:00
#![allow(clippy::redundant_closure)]
2020-12-20 07:20:52 -05:00
#![deny(missing_docs)]
2020-06-13 13:47:20 -04:00
#[macro_use]
mod utils;
mod buffer;
pub mod escape;
pub mod filter;
mod html_escape;
mod render;
#[doc(hidden)]
2020-06-04 16:39:33 -04:00
pub mod runtime;
mod size_hint;
pub use buffer::Buffer;
pub use escape::{Escape, EscapeJsonString};
pub use html_escape::EscapeHtml;
2024-03-15 19:37:12 -04:00
pub use render::{
default_render_escaped, default_render_once_escaped, Render, RenderError, RenderOnce,
RenderResult,
};
pub use size_hint::SizeHint;
2020-06-04 16:39:33 -04:00
#[cfg(feature = "derive")]
2020-12-17 03:06:34 -05:00
#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
2024-03-11 17:33:11 -04:00
pub use sailfish_macros::{Render, RenderOnce};