Giter VIP home page Giter VIP logo

Comments (2)

booyaa avatar booyaa commented on June 6, 2024 1

I was about to file a bug when I found this issue. It's reversing the order of the escaped items.

test code

use liquid::{Renderable, Context, Value};

let template = liquid::parse(
r"{% raw %}
{{ abc }}
{{ def }}
{{ ghi }}
{% endraw %}", Default::default()).unwrap();

let mut context = Context::new();
context.set_val("num", Value::Num(4f32));

let output = template.render(&mut context);
assert_eq!(output.unwrap(), Some("\n{{ abc }}\n{{ def }}\n{{ ghi }}\n".to_string()));

I'm going to have a go a see if I can fix it!

from liquid-rust.

booyaa avatar booyaa commented on June 6, 2024

I'm getting a bit confused, I thought this was a fault with the raw block, but my latest findings would indicate otherwise.

I jumped straight into the raw block code and added a new test that should fail.

#[test]
fn test_raw_ordered() {
    use std::default::Default;

    let options: LiquidOptions = Default::default();
    let raw = raw_block("raw",
                        &[],
                        &vec![Expression(vec![], "{{abc}}\n{{def}}\n{{ghi}}".to_owned())],
                        &options);
    assert_eq!(raw.unwrap().render(&mut Default::default()).unwrap(),
               Some("{{abc}}\n{{def}}\n{{ghi}}".to_owned()));
}

It didn't fail, it passed!

Yet my test code still fails. I've cleaned up the code from last update.

fn main() {
    use liquid::Renderable;

    let template = liquid::parse(r"{% raw %}
{{ abc }}
{{ def }}
{{ ghi }}
{% endraw %}", Default::default()).unwrap();

    let output = template.render(&mut Default::default());
    assert_eq!(output.unwrap(),
               Some("\n{{ abc }}\n{{ def }}\n{{ ghi }}\n".to_string()));
}

Wondering I should look next? I'm thinking the parser or render calls?

from liquid-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.