GithubHelp home page GithubHelp logo

pug-linker's Introduction

pug-linker's People

Contributors

forbeslindesay avatar hemanth avatar timothygu avatar wolfgang42 avatar

Stargazers

 avatar

Watchers

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

pug-linker's Issues

Add tests

We should add the necessary tests to cover all the code/branches, not just import all the tests from jade here.

We should also make sure in particular that we cover the edge case of jade.compile('') and of extending an empty template.

Plugin API

I'm not that confident what a plugin API for the linker should look like, but my current thinking is to have the following hooks:

  1. pre-link (gets given asts that are about to be linked)
  2. pre-extend (gets given the parent ast and the child ast before any blocks have been resolved)
  3. extend (gets given the parent ast and child ast before any blocks have been resolved, but then skips built in block resolving)
  4. post-extend (gets given the parent ast and the child ast after blocks have been resolved)
  5. pre-include (gets include node before yield has been applied)
  6. include (gets include node before yield has been applied, but skips applying yield)
  7. post-include (gets include after yield has been applied)
  8. post-link (gets given asts after all other linking is done)

We should handle raw/filtered includes somewhere else so they don't feature in this proposed plugin API.

Allow 'include' to work in a .pug file, for a .pug file

When I have a .pug file, I can't include external .pug files, without getting an error. I can include a .jade file from a source .pug file without issue. Going to assume for now, that we shouldn't migrate extensions over to .pug, even though 2/3rd of the renaming seems to be done?

The associated error happens on an include of anything other than a .jade file, including non-existent files, .txt files, etc.:

TypeError: Cannot read property 'replace' of undefined
   at before (node_modules/pug-linker/index.js:104:48)
   at walkAST (node_modules/pug-walk/index.js:13:26)
   at node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (node_modules/pug-walk/index.js:20:29)
   at applyIncludes (node_modules/pug-linker/index.js:102:10)
   at link (node_modules/pug-linker/index.js:21:9)
   at compileBody (node_modules/pug/lib/index.js:84:11)
   at Object.exports.compile (node_modules/pug/lib/index.js:164:16)
   at handleTemplateCache (node_modules/pug/lib/index.js:137:25)
   at Object.exports.renderFile (node_modules/pug/lib/index.js:331:10)
   at Object.exports.renderFile (node_modules/pug/lib/index.js:321:21)
   at View.exports.__express [as engine] (node_modules/pug/lib/index.js:368:11)
     ...

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.