parent
7fde2aafb1
commit
cf0cf095c2
3 changed files with 18 additions and 44 deletions
|
@ -158,11 +158,6 @@ impl<'cx, 'i> Parser<'cx, 'i> {
|
|||
let func = try!(self.splice(sp));
|
||||
self.render.emit_call(func);
|
||||
},
|
||||
[pound!(), ident!(sp, name), ..] if name.name == "call_box" => {
|
||||
self.shift(2);
|
||||
let func = try!(self.splice(sp));
|
||||
self.render.emit_call_box(func);
|
||||
},
|
||||
// Splice
|
||||
[ref tt @ dollar!(), dollar!(), ..] => {
|
||||
self.shift(2);
|
||||
|
|
|
@ -198,16 +198,6 @@ impl<'cx> Renderer<'cx> {
|
|||
let stmt = self.wrap_try(expr);
|
||||
self.push(stmt);
|
||||
}
|
||||
|
||||
pub fn emit_call_box(&mut self, func: P<Expr>) {
|
||||
let w = self.writer;
|
||||
let expr = quote_expr!(self.cx,
|
||||
::std::boxed::FnBox::call_box(
|
||||
$func,
|
||||
(&mut *$w as &mut ::std::fmt::Write,)));
|
||||
let stmt = self.wrap_try(expr);
|
||||
self.push(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
fn html_escape(s: &str) -> String {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#![feature(fnbox, plugin)]
|
||||
#![feature(plugin)]
|
||||
#![plugin(maud_macros)]
|
||||
|
||||
extern crate maud;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
#[test]
|
||||
fn literals() {
|
||||
let mut s = String::new();
|
||||
|
@ -272,35 +274,22 @@ mod issue_10 {
|
|||
}
|
||||
}
|
||||
|
||||
mod subtemplates {
|
||||
use std::fmt;
|
||||
|
||||
#[test]
|
||||
fn call() {
|
||||
fn ducks(w: &mut fmt::Write) -> fmt::Result {
|
||||
write!(w, "Ducks")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call() {
|
||||
let mut s = String::new();
|
||||
let swans = |yes|
|
||||
if yes {
|
||||
|w: &mut fmt::Write| write!(w, "Swans")
|
||||
} else {
|
||||
panic!("oh noes")
|
||||
};
|
||||
html!(s, {
|
||||
#call ducks
|
||||
#call (|w: &mut fmt::Write| write!(w, "Geese"))
|
||||
#call swans(true)
|
||||
}).unwrap();
|
||||
assert_eq!(s, "DucksGeeseSwans");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_box() {
|
||||
let mut s = String::new();
|
||||
let ducks = Box::new(ducks);
|
||||
html!(s, #call_box ducks).unwrap();
|
||||
assert_eq!(s, "Ducks");
|
||||
}
|
||||
let mut s = String::new();
|
||||
let swans = |yes|
|
||||
if yes {
|
||||
|w: &mut fmt::Write| write!(w, "Swans")
|
||||
} else {
|
||||
panic!("oh noes")
|
||||
};
|
||||
html!(s, {
|
||||
#call ducks
|
||||
#call (|w: &mut fmt::Write| write!(w, "Geese"))
|
||||
#call swans(true)
|
||||
}).unwrap();
|
||||
assert_eq!(s, "DucksGeeseSwans");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue