parent
af60d7c3ec
commit
8eb655207e
2 changed files with 7 additions and 5 deletions
|
@ -171,11 +171,11 @@ pub fn escape(s: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Use `.render()` to convert it to a `String`, or `.render_to()` to
|
/// Use `.render()` to convert it to a `String`, or `.render_to()` to
|
||||||
/// write it directly to a handle.
|
/// write it directly to a handle.
|
||||||
pub struct Markup<'a> {
|
pub struct Markup<F> {
|
||||||
callback: &'a (Fn(&mut fmt::Writer) -> fmt::Result + 'a),
|
callback: F,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Markup<'a> {
|
impl<F> Markup<F> where F: Fn(&mut fmt::Writer) -> fmt::Result {
|
||||||
/// Render the markup to a `String`.
|
/// Render the markup to a `String`.
|
||||||
pub fn render(&self) -> String {
|
pub fn render(&self) -> String {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
|
@ -218,7 +218,9 @@ pub mod rt {
|
||||||
use super::Markup;
|
use super::Markup;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn make_markup<'a>(f: &'a (Fn(&mut fmt::Writer) -> fmt::Result + 'a)) -> Markup<'a> {
|
pub fn make_markup<F>(f: F) -> Markup<F>
|
||||||
|
where F: Fn(&mut fmt::Writer) -> fmt::Result
|
||||||
|
{
|
||||||
Markup { callback: f }
|
Markup { callback: f }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl<'cx, 's, 'o> Renderer<'cx, 's, 'o> {
|
||||||
render.cx
|
render.cx
|
||||||
};
|
};
|
||||||
quote_expr!(cx,
|
quote_expr!(cx,
|
||||||
::maud::rt::make_markup(&|&: $w: &mut ::std::fmt::Writer| -> Result<(), ::std::fmt::Error> {
|
::maud::rt::make_markup(|&: $w: &mut ::std::fmt::Writer| -> Result<(), ::std::fmt::Error> {
|
||||||
$stmts
|
$stmts
|
||||||
Ok(())
|
Ok(())
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Add table
Reference in a new issue