Add support for dot notation
thesurlydev opened this issue · 4 comments
thesurlydev commented
For example,
{{#some_value}}
{{.}}
{{/some_value}}
Th3Whit3Wolf commented
I am looking to add this to the rust template benchmark but I think dot notation is required to do it properly.
maciejhirsz commented
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 commented
@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 commented
Is there a way to do something like {{a.b.c}}
, right now it doesn't seem to work.