Search code examples
phpwordpresshtmlpug

How to place php code in body tag using Jade?


how can I write this in Jade?

<body <?php body_class(); ?>>

I tried like this

body(!{"<?php body_class(); ?>"})

but does not work.

The solutions offered in Is it possible to write PHP in jade/pug? do not work in this specific case.

Is there any way of doing this?

I use codekit for compiling offline.


Solution

  • For Jade, you should escape the entire string like this
    header.jade

    doctype
    | <html <?php language_attributes(); ?>>
    
    head
      meta(charset!='<?php bloginfo("charset") ?>')
      meta(name='viewport' content='width=device-width')
      link(rel='profile' href='http://gmpg.org/xfn/11')
      link(rel='stylesheet' href!="<?= get_bloginfo('stylesheet_directory'); ?>/style.css?v=#{version}" type='text/css')
      link(rel="pingback" href!="<?php bloginfo( 'pingback_url' ); ?>")
      - wp_head()
    
    | <body <?php body_class(); ?>>
    

    footer.jade

    script(src!="<?= get_bloginfo('stylesheet_directory'); ?>/core.js?v=#{version}")
    
    - wp_footer()
    
    | </body></html>