jademagic

an IPython magic for authoring HTML in Jade ne Pug.

Install

From the command line (or with ! in a notebook cell):

pip install jademagic

Enable

Ad-hoc

In the notebook, you can use the %load_ext or %reload_ext line magic.


In [32]:
%reload_ext jademagic

Configuration

In your profile's ipython_kernel_config.py, you can add the following line to automatically load jademagic into all your running kernels:

c.InteractiveShellApp.extensions = ['jade_magic']

Use

The %%jade cell magic will either act as simple parser:


In [33]:
%%jade
ul
    each x in [1, 2, 3, 4, 5]
        li: i.fa.fa-gift(class='fa-#{x}x')


Out[33]:

which can be accessed by the special last result variable _:


In [34]:
_


Out[34]:

Or will update a named variable with the parsed document:


In [35]:
%%jade spock
i.fa.fa-spock.fa-5x



In [36]:
spock


Out[36]:
'<i class="fa fa-spock fa-5x"></i>'

Contribute

Issues and pull requests welcome!

License

jademagic is released as free software under the BSD 3-Clause license.

Thank

  • @lbustelo for challenging me to an alternative to %%html