use filter in javascript code #117

Open
lukeman83 opened this Issue Feb 4, 2013 · 3 comments

Projects

None yet

3 participants

@lukeman83

Hi,
what is the best way to use filters into javascript code?

@avalanche123
Owner

All you'd need to do is generate correct url, I suggest trying filters in templates to see how the url looks like and replicating generation of url in javascript

@lukeman83
@jaskra

I recently used a filter in javaScript like this

function f(response) {
  var rurl = '{{ 'PLACEHOLDER' | apply_filter('my_thumb') }}';
       rurl = rurl.replace(PLACEHOLDER, response.url);
  $('#images').append('< img src="' + rurl + '" alt="" />');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment