Bind Liquid Template Filter to a Context

Viewed 1413

I would like to be able to bind a Rails Liquid Template filter to a context.

For example, say I have a filter called 'asset_url' that I would like to use as follows:

{{ 'style.css' | asset_url }}

I would like the asset_url filter to be able to lookup the key 'style.css' on a per user-account basis like so:

https://somewhere.com/users/10/assets/style.css

Notice that I need to retrieve the asset_url for user_id=10.

Is there a way for me to bind/initialize an arbitrary context to a Liquid filter?

Thanks,

1 Answers
Related