GithubHelp home page GithubHelp logo

docpad-archive / docpad-plugin-jade Goto Github PK

View Code? Open in Web Editor NEW
17.0 19.0 8.0 72 KB

Adds support for the Jade templating engine to DocPad.

License: Other

CoffeeScript 96.18% HTML 3.82%
unsupported jade docpad-plugin

docpad-plugin-jade's Introduction

Jade Plugin for DocPad

Travis CI Build Status NPM version NPM downloads Dependency Status Dev Dependency Status
Slack community badge Patreon donate button Gratipay donate button Flattr donate button PayPal donate button Bitcoin donate button Wishlist browse button

Adds support for the Jade templating engine to DocPad

Convention: .anything.jade

Install

docpad install jade

Deprecated

Jade was renamed to Pug, as such the Jade plugin is deprecated. Use docpad-plugin-pug instead.

Awareness

Before you get started with Jade, it is important to be aware of one thing. The majority of support questions that come through with DocPad, aren't actually DocPad issues, but Jade issues. People confusing the syntax, Jade doing it's own templating magic, things like that.

The DocPad team recommends you try one of the many other amazing templating engines that are available, over trying to use Jade.

If you still insist on using Jade, please be aware, Jade will be a slippery slope, but luckily there are determined Jade users here to help :)

Usage

Template Helpers as Filters

Use just like any jade template. However, we do add any docpad template helpers you may have as jade filters. There are two ways you can use these filters:

-# first way, calls the template helper like: myTemplateHelper("content", {opt1="blah",opt2="blah",opt3=true})
:myTemplateHelper(opt1=blah,opt2=blah,opt3)
    content

-# second way, calls the template helper like: myTemplateHelper(arg1, arg2)
:myTemplateHelper(args)
    arg1
    arg2

NOTE: Not all template helpers support being called this way. If it doesn't work, we'd recommend using the text plugin to render eco which includes your template helper call. See following section.

Jade :filters

Since 1.10.0 Jade supports jstransformers, which allows improved handling of embedded languages such as Coffee-Script, and deprecated Transformers support in filters - to be removed in 2.0.0.

All JSTransformers can now be used as jade filters.

Rendering with the Text Plugin

You can use the text plugin to render different parts of your template with different markups that are support by your docpad setup. Once installed, you can do things like:

:t(render="markdown")
    here is some *markdown*

:t(render="html.md.eco")
    here is some <%-'eco'.toUpperCase()%> to *markdown* to html

:t(render="html.eco")
    my url is <%[email protected]%>

History

Discover the release history by heading on over to the HISTORY.md file.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Patreon donate button Gratipay donate button Flattr donate button PayPal donate button Bitcoin donate button Wishlist browse button

Contributors

These amazing people have contributed code to this project:

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

License

Unless stated otherwise all works are:

and licensed under:

docpad-plugin-jade's People

Contributors

balupton avatar craigmdennis avatar darky avatar kizu avatar phaseone avatar romanpitak avatar toabi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docpad-plugin-jade's Issues

Content duplicated

I'm doing a new website using DocPad, Jade and Markdown but whenever I try and render the content of a page (written in Markdown) is duplicated in the generated HTML.

Here's my Jade template (/src/layouts/default.html.jade):

!!! 5
html.no-js(lang='en')
  head
  body
    #{content}

Here's my Markdown file (/src/documents/default.html.md):


---
title: "My title"
layout: "default"
isPage: true

---

# Hello world

This is a test

Here's the generated output (/out/default.html):

<!DOCTYPE html>
<html lang="en" class="no-js">
  <head>
  </head>
  <body>
    <<h1>Hello world</h1>
<p>This is a test</p>
></<h1>Hello world</h1>
<p>This is a test</p>
>
  </body>
</html>

As you can see the Markdown is duplicated and a > has appeared from somewhere.

My current setup is:

  • DocPad 6.35.0
  • Node.js 0.10.8
  • Jade plugin latest
  • Marked plugin latest
  • Text plugin latest

Any idea why the content is duplicated?

Sending Locals with Docpad API

Is a good idea to send some locals to the plugin Via the Docpad API, something i need to do requires the use of some javascript mixins and i cant send it when serving the document on express.

tried this:

docpadInstance.serveDocument({
    document: document,
    req: req,
    res: res,
    next: next,
    locals:{
       val:rval
     }
});

Add a warning about jade problems

I'm considering adding the following to this plugin:


Awareness

Before you get started with Jade, it is important to be aware of one thing. The majority of support questions that come through with DocPad, aren't actually DocPad issues, but Jade issues. People confusing the syntax, Jade doing it's own templating magic, things like that.

Adding onto this, Jade is one of the slowest templating engines there is source, and will quickly become the bottleneck in large projects.

The DocPad team recommends you try one of the many other amazing templating engines that are available, over trying to use Jade.

If you still insist on using Jade, please be aware, you may be treading down a slippery slope.


Does anyone have a problem with this?

One Jade scope for layouts and documents

Is there any way to make the layouts and documents to be in one scope? So I could define Jade's mixins and variables in one layout file and then reuse them in the documents?

Right now I need to manually write the includes for my mixins.jade in every document and layout, and it's not fun.

Jade to Pug Migration

As far as I am know, jade will cease to exist and change to pug. Hence, I guess this plugin should be updated.

double indentation causes "unexpected token "indent"" error

I have a file called index.html.jade, and docpad gives me this error at render:
warning: Something went wrong while rendering: index.html.jade
unexpected token "indent"

to reproduce the bug, I made this reduced test case:

div
  div
    div

If the file contains this, It will give me the error.

Text plugin broken in Jade

docpad: 6.30.0
docpad-plugin-jade: 2.3.1
node: 0.8.14
os: OSX 10.8.3

Doing the following in my jade template works:

:t(render="markdown")
    here is some *markdown*

But it breaks when I add more content under the template helper:

:t(render="markdown")
    here is some *markdown*

p More HTML

This is the error I get:

error: An error occured:
SyntaxError: Unexpected token ILLEGAL
    at Object.Function (unknown source)
    at Object.exports.compile (/Users/mikemurray/Desktop/mikemurray.me/node_modules/docpad-plugin-jade/node_modules/jade/lib/jade.js:176:8)
    at JadePlugin.module.exports.JadePlugin.render (/Users/mikemurray/Desktop/mikemurray.me/node_modules/docpad-plugin-jade/out/jade.plugin.js:77:36)
    at ambi (/usr/local/lib/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:21:27)
    at DocPad.BasePlugin.bindEvents (/usr/local/lib/node_modules/docpad/out/lib/plugin.js:90:18)
    at ambi (/usr/local/lib/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:21:27)
    at Task.EventEmitterEnhanced.getListenerGroup (/usr/local/lib/node_modules/docpad/node_modules/bal-util/out/lib/events.js:36:16)
    at ambi (/usr/local/lib/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:21:27)
    at Task.run (/usr/local/lib/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:78:19)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Object #<Object> has no method 'referencesOthers'

Install the current DocPad (6.45) and install the "Twitter Bootstrap with Jade" skeleton. Then docpad generate:

davebook.dave ~/Dropbox/Projects/blog.docpad/test $ docpad generate
info: Welcome to DocPad v6.45.0
info: Plugins: cleanurls, coffeescript, eco, jade, less, livereload, marked, partials, related, stylus, text
info: Environment: development
info: Generating...
warning: Something went wrong while rendering: pages/posts.html.jade
error: Something went wrong with the action
error: An error occured:
TypeError: /Users/dave/Dropbox/Projects/blog.docpad/test/src/documents/pages/posts.html.jade:2
    1| ---
  > 2| title: Posts
    3| layout: page
    4| pageOrder: 2
    5| ---

Object #<Object> has no method 'referencesOthers'
    at initialTemplateData.getCollection (/usr/local/lib/node_modules/docpad/out/lib/docpad.js:621:16)
    at eval (eval at <anonymous> (/Users/dave/Dropbox/Projects/blog.docpad/test/node_modules/docpad-plugin-jade/node_modules/jade/lib/jade.js:170:8), <anonymous>:13:15)
    at eval (eval at <anonymous> (/Users/dave/Dropbox/Projects/blog.docpad/test/node_modules/docpad-plugin-jade/node_modules/jade/lib/jade.js:170:8), <anonymous>:75:4)
    at /Users/dave/Dropbox/Projects/blog.docpad/test/node_modules/docpad-plugin-jade/node_modules/jade/lib/jade.js:171:35
    at JadePlugin.render (/Users/dave/Dropbox/Projects/blog.docpad/test/node_modules/docpad-plugin-jade/out/jade.plugin.js:74:70)
    at ambi (/usr/local/lib/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:21:27)
    at Task.<anonymous> (/usr/local/lib/node_modules/docpad/node_modules/bal-util/out/lib/events.js:38:16)
    at ambi (/usr/local/lib/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:21:27)
    at /usr/local/lib/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:82:19
    at process._tickDomainCallback (node.js:459:13)

Unexpected token ILLEGAL

Thanks for a great platform (and plugin)

But I'm really having a hard time converting my HTML5 Boilerplate based Eco templates to Jade. The stack-traces make little sense and make debugging hard - I've had to resort to adding log-statements at various points in the parser codebase to see what the failing expression was etc.

Case in point:
I'm getting an error "Unexpected token ILLEGAL" and a pointer to the last line in my default template. I initially thought it had to do with line endings (LF/CRLF) but my template is Unix encoded and all seems to be in order.

Any help getting around this is appreciated. I'm staying away from Jade templates until I find a better way to debug them.

Thanks!

Properties from templateData and helpers are not copied to *this*

I am defining some data in docpad config

templateData:
    site:
        navigation: [
            { href:'/#', label:'home' }
            { href:'/#what-we-do', label:'what we do' }
            { href:'/#clients', label:'clients' }
            { href:'/#blog', label:'blog' }
            { href:'/#contact', label:'contact' }
        ]

site is available in the scope of a page and template, but it is not a member of this.
This raises problems when i am using partials plugin and passing the scope to it !=partial("sections/header.html.jade", this)
At that moment the following evaluations result in false

hasOwnProperty('site')
hasOwnProperty('getFilesAtPath')

This is different to how it behaves on the default parser for .eco files. Where they evaluate to true and the same config variables are also accessed inside the partial.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.