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

Custom filters not working with include:filter #2440

Closed
dcposch opened this issue Jul 4, 2016 · 4 comments · Fixed by pugjs/pug-filters#19
Closed

Custom filters not working with include:filter #2440

dcposch opened this issue Jul 4, 2016 · 4 comments · Fixed by pugjs/pug-filters#19

Comments

@dcposch
Copy link

dcposch commented Jul 4, 2016

Steps to reproduce

1. Make a custom filter

pug.filters.myfilter = (text, options) => {
  console.log('TEXT', text)
  console.log('OPTIONS', options)
  return text.toLowerCase()
}

2. Use it in a block. Works fine.

block body
  :myfilter
    TESTING 123

...if you run that, the page reads 'testing 123', and here's the console:

TEXT: TESTING 123
OPTIONS: {'filename': '[...]/test.pug'}

3. Use it together with include. Doesn't work.

block body
  include:myfilter myfile.txt

...if you run that, the page just contains the full path to myfile.txt, not the contents! Here's the console:

TEXT: [...]/myfile.txt
OPTIONS: {'filename': '[...]/myfile.txt'}

When you use include:myfilter, Pug should read the file and pass the contents to the filter, not pass the filename, right?

@ayroblu
Copy link

ayroblu commented Jul 12, 2016

Would also like to add a new test case to handle this, but I'm not familiar with how you generate them?

@TimothyGu
Copy link
Member

TimothyGu commented Jul 13, 2016

I opened a ticket in pugjs/pug-filters#18 for the addition of a test case.

Custom filter testing is a bit more complicated.

@ForbesLindesay
Copy link
Member

Re-opening until someone has confirmed that the update still works with builtin filters.

@TimothyGu
Copy link
Member

Really fixed in pug-filters@1.2.3/pug@2.0.0-beta4.

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

Successfully merging a pull request may close this issue.

4 participants