New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Changes #2305

Open
ForbesLindesay opened this Issue Apr 13, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@ForbesLindesay
Member

ForbesLindesay commented Apr 13, 2016

This issue lists known breaking changes from jade to pug@2.0.0. If you think you've found another breaking change, please open a separate issue so it can be triaged. I'm going to lock this issue to collaborators only.

General Changes

  • include and extend both default to adding a .pug extension if there is no extension, rather than a .jade extension. You should ideally rename all .jade files to .pug files, failing that you will need to explicitly add a .jade extension to include and extend statements.

Removed/Changed syntax

Old New Explanation
mixin foo('whatever') +foo('whatever') We removed the legacy syntax for calling a mixin to make it easier to differentiate between declaration and calls
a(href="#{link}")
a(href='before#{link}after')
a(href=link)
a(href=`before${link}after`) (on Node.js/io.js ≥ 1.0.0)
a(href='before' + link + 'after') (everywhere)
We removed support for interpolation in attributes since it was unnecessarily complex in implementation and tended to delay users learning that they can just use any JavaScript value in place of attributes
- each a in b each a in b each is not part of the JavaScript syntax, so the use of each "keyword" in a JavaScript line is confusing as well as hackish (in terms of implementation). Simply remove and your code should work again.

Changed Output

Input Old New Explanation
input(value=new Date()) <input value="Wed Apr 13 2016 14:36:25 GMT+0100 (BST)"/> <input value="2016-04-13T13:36:25.000Z"/> We now always use the ISO representation of dates
input(value={some: 'object'}) <input value="[object Object]"/> <input value='{"some":"object"}'/> We used to only JSON.stringify if the attribute started with data-. We've made this more consistent.

Removed APIs

Most of the removed APIs never should have been public in the first place: they make it possible to pollute modules visible in the global scope.

Exported Explanation
selfClosing Custom self-closing tags WILL be allowed as a plugin to pug-code-gen.
doctype Custom doctypes WILL be allowed as a plugin to pug-code-gen.
utils utils.merge is now unneeded in the Pug code base. If you need it there are many excellent object merge packages out there on npm.
utils.stringify has been split into a new package “js-stringify.”
utils.walkAST is now “pug-walk” package.
Compiler You should either use pug-code-gen plugins which has not been implemented yet, and will be specified in the options, or if we decide in the future that we want to allow completely overriding the code generator, do that.
Parser You should either use pug-parser plugins which is specified in the options, or if we decide in the future that we want to allow completely overriding the parser, do that.
Lexer You should either use pug-lexer plugins which is specified in the options, or if we decide in the future that we want to allow completely overriding the lexer, do that.
nodes We have abandoned the approach of having a class for every node and started using duck typing with AST property type.

@pugjs pugjs locked and limited conversation to collaborators Apr 13, 2016

@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu

TimothyGu Apr 18, 2016

Member

Added some info.

Member

TimothyGu commented Apr 18, 2016

Added some info.

@ForbesLindesay

This comment has been minimized.

Show comment
Hide comment
@ForbesLindesay

ForbesLindesay Apr 18, 2016

Member

We're still adding a default extension of .pug if the filename does not contain a . (see:

pug/lib/index.js

Lines 53 to 63 in 610972b

tokens = tokens.map(function (token) {
if (token.type === 'path' && token.val.indexOf('.') === -1) {
return {
type: 'path',
line: token.line,
col: token.col,
val: token.val + '.pug'
};
}
return token;
});
). This means that we do not support importing files without an extension, but that's never come up as a feature request. We could consider deprecating it, but should add a warning if we do.

Member

ForbesLindesay commented Apr 18, 2016

We're still adding a default extension of .pug if the filename does not contain a . (see:

pug/lib/index.js

Lines 53 to 63 in 610972b

tokens = tokens.map(function (token) {
if (token.type === 'path' && token.val.indexOf('.') === -1) {
return {
type: 'path',
line: token.line,
col: token.col,
val: token.val + '.pug'
};
}
return token;
});
). This means that we do not support importing files without an extension, but that's never come up as a feature request. We could consider deprecating it, but should add a warning if we do.

@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu

TimothyGu Apr 18, 2016

Member

Oops. Thanks for noticing it.

Member

TimothyGu commented Apr 18, 2016

Oops. Thanks for noticing it.

@tjconcept

This comment has been minimized.

Show comment
Hide comment
@tjconcept

tjconcept Jul 9, 2016

Member

Context: I am currently upgrading a project from Jade to the newest Pug, and I am just dumping whatever bites me on the way here.

  • Removing the CLI from this package (so I had to change jade to pug-cli in my package.json)
  • Removing the --hierarchy option
Member

tjconcept commented Jul 9, 2016

Context: I am currently upgrading a project from Jade to the newest Pug, and I am just dumping whatever bites me on the way here.

  • Removing the CLI from this package (so I had to change jade to pug-cli in my package.json)
  • Removing the --hierarchy option
@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu

TimothyGu Jul 13, 2016

Member

@tjconcept

  • Removing the CLI from this package (so I had to change jade to pug-cli in my package.json)

The CLI was removed in jade@1.11.0 also, I believe.

  • Removing the --hierarchy option

That's true. I might just make it a noop.

Member

TimothyGu commented Jul 13, 2016

@tjconcept

  • Removing the CLI from this package (so I had to change jade to pug-cli in my package.json)

The CLI was removed in jade@1.11.0 also, I believe.

  • Removing the --hierarchy option

That's true. I might just make it a noop.

zenithtekla referenced this issue in zenithtekla/nodeMySQL Sep 30, 2016

r56 will soon require Webpack|Brunch or other build tools
- progressing on client side development, it becomes opinionated on the point to decide whether to continue with pug as main template and employ a build tool to render html files on load to integrate AngularJS better and SCSS to css.
- or revert the layout and other core views files to html with ejs
- The back-end code is pending migration to Angular2-Universal or Angular2-MeteorJS for better, agile, isomorphic, universal dev, ES6 import instead of require('module')..
- If MongoDB is used in the dev and prod,MEANJS stack or  Angular2-MeteorJS framework can be used right away without having to go through hoops of engineering this NodeMySQL app
- But as relational databases still prevail, NodeJS and MeteorJS dev requires some efforts wiring Sequelize and back-end RESTful coding to engineer the app
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.