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

Runtime Filters #1714

Open
mathiasschopmans opened this issue Nov 8, 2014 · 2 comments
Open

Runtime Filters #1714

mathiasschopmans opened this issue Nov 8, 2014 · 2 comments

Comments

@mathiasschopmans
Copy link

I'm using Jade as a static prototype generator and would like to render some html-docs for my custom components, mixins, snippets to support my colleagues, which are integrating my html templates into different CMS.

helpers.jade

mixin code-example(name, options)
  - options = extend({"html":true, "jade":true, "render":true}, options)
  .code-example
    h3.name= name

    if options.html
      pre.code.code-html(data-language="html")
        :examplehtml
          block

    if options.jade
      pre.code.code-jade(data-language="jade")
        :examplejade
          block

  if options.render
    block

usage.jade

+code-example("Tabs")
  +tabs()
    each tab, num in ["One", "Two", "Three"]
      +tab(tab)
        h1 Content Tab #{num}
  • :examplehtml should be a basic jade wrapper which will return the rendered, but escaped html.
  • :examplejade will be a basic wrapper to return the escaped jade

Do you know how to access the block from filters?

Thank you!

@ForbesLindesay ForbesLindesay added this to the 3.0.0 milestone Oct 5, 2015
@shroudedcode
Copy link

@mathiasschopmans Great suggestion, this would simplify the implemenation of code example boxes like the one below (from the Primer CSS documentation) while keeping your code DRY.

Primer CSS documentation code example

@ForbesLindesay ForbesLindesay changed the title [Feature Request] Support block inside :filter Runtime Filters Sep 6, 2017
@brunowego
Copy link

Is there any way around this? Force block work inside a filter...

mixin highlight(lang = 'html')
  pre
    code(class=lang)
      :escape-html:html-beautify:pug
        block
"jstransformer-escape-html": "~1.1.0",
"jstransformer-html-beautify": "0.0.1",
"jstransformer-pug": "~0.3.0",

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

No branches or pull requests

4 participants