SE7ENSKY / jade2php

Unlock Jade for PHP! Convert Jade templates into raw PHP templates. CLI tool and JavaScript API. Test covered.
43 stars 10 forks source link

Support PHP functions inside html tags #11

Open janwirth opened 9 years ago

janwirth commented 9 years ago

There is no way to do this: http://codex.wordpress.org/Function_Reference/body_class

ivankravchenko commented 9 years ago

definitely :) On my WP themes, body_class is just not used. How do you see body_class can be correctly called in jade? I think, this particular case needs a workaround. For example, using &attributes, body&attributes(bodyAttributes), where bodyAttributes is passed into template.

janwirth commented 9 years ago

what about =body_class() escaped and !=body_class() unescaped. Seems like the most logical succession to me.

or maybe #{body_class()}

I'd like to try it out, but i barely have any brain juice left for today.

ivankravchenko commented 9 years ago

Brain juice ;) As for me, Jade have no direct equialent to <body <?php body_class() ?>> code. Actually, one possible direct workaround is:

doctype html
html
  head
    title An ugly workaround with WP's body_class()
  | <body !{body_class()}>
  h1 Eh?
  | </body>

Supposably, my previous suggestion with &attributes is better.

janwirth commented 9 years ago

So if I am getting this right, a tag using this feature may look like this a(href='#')&(phpFunction()).linkClass A link as supposed to this a(href='#' =phpFunction()).linkClass A link

ivankravchenko commented 9 years ago

a(href='#' =phpFunction()).linkClass A link isn't correct Jade code. a(href='#')&(phpFunction()).linkClass A link possible, but if phpFunction() return data in some special format. I think body_class() is not applicable here. I'll think about this.

P.S.: I am also using jade2php on WordPress templates, I need to share my work :)