Open
Description
Hello!
I'm working on supporting Shopify's t
filter (translation filter).
Here there is a simple a example of how it works. If we have the following translations file
/locales/en.default.json
{
"layout": {
"header": {
"hello_user": "Hello {{ name }}!"
}
}
}
And the following liquid template:
<h1>{{ 'layout.header.hello_user' | t: name: customer.first_name }}</h1>
We would expect this example to render (assuming the first name of the customer is John):
<h1>Hello John</h1>
I'm running into the following issue when implementing this as a custom filter.
This is how I'm defining the filter's parameters:
#[derive(Debug, FilterParameters)]
struct TArgs {
#[parameter(
description = "Variables to be used for revaluating liquid once translation is resolved.",
)]
variables: Option<Expression>,
}
#[derive(Clone, ParseFilter, FilterReflection)]
#[filter(
name = "t",
description = "Access the desired translation for the recipient local",
parameters(TArgs),
parsed(TFilter)
)]
pub struct T;
#[derive(Debug, FromFilterParameters, Display_filter)]
#[name = "t"]
struct TFilter {
#[parameters]
args: TArgs,
}
But the problem is that when I run the same example I get the following error:
"liquid: Unexpected named argument `name`\nfrom: Filter parsing error\n with:\n filter=t: name: customer.name\n"}
I haven't been able to get the filter working with object literals with arbitrary keys. What's the best way to accomplish this?
Metadata
Metadata
Assignees
Labels
No labels