pub fn parse_with_options(&self, options: &Options, data: &str)
        -> Result<render::Template, ParseError>
    {
        use combine::combinator::{skip_many, parser};
        use tokenizer::Kind::{EarlyStatement, Comment};
        use helpers::{kind};

        let options = self.pre.scan(data, options.clone())?;
        let s = self.tok.scan(data);

        let mut p =
            skip_many(kind(EarlyStatement).or(kind(Comment)))
            .with(parser(body)).skip(kind(Kind::Eof));

        let (body, _) = p.parse(s)?;
        let body = match options.syntax {
            Syntax::Oneline => {
                // easier after optimizer
                let body = self.optimizer.optimize(&options, body);
                self.oneline_post.process(&options, body)
            }
            Syntax::Indent => {
                // easier before optimizer
                let body = self.indent_post.process(&options, body)?;
                self.optimizer.optimize(&options, body)
            }
            Syntax::Plain => {
                self.optimizer.optimize(&options, body)
            }
        };
        let tpl = Template {
            options: options,
            body: body,
        };
        // TODO(tailhook) should we assert EOF?
        // TODO(tailhook) execute checks
        return Ok(template(tpl));
    }
/// Parse and compile a template with some predefined options set
Parse and compile a template with some predefined options set
Parse and compile a template with some predefined options set
pub fn parse_with_options(&self, options: &Options, data: &str)
        -> Result<render::Template, ParseError>
    {
        use combine::combinator::{skip_many, parser};
        use tokenizer::Kind::{EarlyStatement, Comment};
        use helpers::{kind};
        let options = self.pre.scan(data, options.clone())?;
        let s = self.tok.scan(data);
        let mut p =
            skip_many(kind(EarlyStatement).or(kind(Comment)))
            .with(parser(body)).skip(kind(Kind::Eof));
        let (body, _) = p.parse(s)?;
        let body = match options.syntax {
            Syntax::Oneline => {
                // easier after optimizer
                let body = self.optimizer.optimize(&options, body);
                self.oneline_post.process(&options, body)
            }
            Syntax::Indent => {
                // easier before optimizer
                let body = self.indent_post.process(&options, body)?;
                self.optimizer.optimize(&options, body)
            }
            Syntax::Plain => {
                self.optimizer.optimize(&options, body)
            }
        };
        let tpl = Template {
            options: options,
            body: body,
        };
        // TODO(tailhook) should we assert EOF?
        // TODO(tailhook) execute checks
        return Ok(template(tpl));
    }
pub fn parse_with_options ( & self , options : & Options , data : & str ) -> Result < render :: Template , ParseError > { use combine :: combinator :: { skip_many , parser } ; use tokenizer :: Kind :: { EarlyStatement , Comment } ; use helpers :: { kind } ; let options = self . pre . scan ( data , options . clone ( ) ) ? ; let s = self . tok . scan ( data ) ; let mut p = skip_many ( kind ( EarlyStatement ) . or ( kind ( Comment ) ) ) . with ( parser ( body ) ) . skip ( kind ( Kind :: Eof ) ) ; let ( body , _ ) = p . parse ( s ) ? ; let body = match options . syntax { Syntax :: Oneline => { // easier after optimizer let body = self . optimizer . optimize ( & options , body ) ; self . oneline_post . process ( & options , body ) } Syntax :: Indent => { // easier before optimizer let body = self . indent_post . process ( & options , body ) ? ; self . optimizer . optimize ( & options , body ) } Syntax :: Plain => { self . optimizer . optimize ( & options , body ) } } ; let tpl = Template { options : options , body : body , } ; // TODO(tailhook) should we assert EOF? // TODO(tailhook) execute checks return Ok ( template ( tpl ) ) ; }
Parse and compile a template with some predefined options set
Parse and compile a template with some predefined options set
&self
options
&Options
data
&str
&self
options
&Options
data
&str