Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dot notation #43

Open
thesurlydev opened this issue Mar 13, 2021 · 4 comments
Open

Add support for dot notation #43

thesurlydev opened this issue Mar 13, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@thesurlydev
Copy link

For example,

{{#some_value}}
{{.}}
{{/some_value}}
@Th3Whit3Wolf
Copy link

I am looking to add this to the rust template benchmark but I think dot notation is required to do it properly.

@maciejhirsz
Copy link
Owner

It shouldn't be too hard to do, I've commented on this in previous issue.

@Th3Whit3Wolf I assume this is mostly for repeated sections?

@Th3Whit3Wolf
Copy link

Th3Whit3Wolf commented Mar 14, 2021

@maciejhirsz yeah I have something like this

#[derive(Content)]
struct BigTable {
    table: Vec<Vec<usize>>,
}

static BIG_TABLE_TEMPLATE: &'static str = "<table>\
{{#table}}\
<tr>{{#.}}<td>{{.}}</td>{{/.}}</tr>\
{{/table}}\
</table>";

pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) {
    let mut table = Vec::with_capacity(*size);
    for _ in 0..*size {
        let mut inner = Vec::with_capacity(*size);
        for i in 0..*size {
            inner.push(Value::Scalar((i as i32).into()));
        }
        table.push(Value::Array(inner));
    }

    let big_table_data = BigTable {
        table
    };

    let template = Template::new(BIG_TABLE_TEMPLATE).unwrap();

    b.iter(|| template.render(&big_table_data {

    }));
}

Where I need to access the value of a Vec<Vec<usize>>

@tusharmath
Copy link

Is there a way to do something like {{a.b.c}}, right now it doesn't seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants