Skip to content
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

Pug 3.0.0 #3258

Closed
ForbesLindesay opened this issue May 24, 2020 · 2 comments
Closed

Pug 3.0.0 #3258

ForbesLindesay opened this issue May 24, 2020 · 2 comments

Comments

@ForbesLindesay
Copy link
Member

I'm intending to publish pug 3.0.0 within the next 24 hours. In the mean time, it would be great if as many people as possible could try out the "canary" build. You can get it by running npm install pug@canary.

I've automated the release process via Rolling Versions so it will now always be possible to install the version currently on the master branch via pug@canary, and new production-ready releases should be much more frequent.

The provisional release notes for pug@3.0.0 are as follows:

Breaking Changes

Features

  • Add support for replacing code gen via a plugin with generateCode (Add the possibility of replacing generateCode function #3230)

  • Support each ... of ... loops (Adding 'each .. of' syntax #3179)

    each value of iterable
      li= value

    This requires an environment that supports the for (const val of iterable) syntax in JS. You can iterate over Maps, Sets etc. as well as arrays. There is also some destructuring of map keys:

    - const map = new Map([['a', 'x'], ['b', 'y']]);
    each [key, value] of map
      li
        strong= key
        = value
  • Support filters that apply to Buffers (Allow filters to read non-text include files #3213)

    e.g.

    // options.js
    exports.filters = {
      png: {
        // instead of a function, specify an object with a "renderBuffer" property
        // whose value is a function that takes a Buffer instead of a string
        renderBuffer: function(buffer, options) {
          var data = Buffer.from(buffer).toString('base64');
          return '<img src="data:image/png;base64, ' + data + '"/>';
        }
      }
    };

    You can then use the filter like:

    // foo.pug
    include:png my-small-image.png
@ForbesLindesay
Copy link
Member Author

Here's the official release: https://github.com/pugjs/pug/releases/tag/pug%403.0.0

@zackschuster
Copy link
Contributor

@ForbesLindesay my node_modules deploys went from 6.8mb to 4.0mb entirely due to the changes for v3. thank you so much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants