Git Product home page Git Product logo

node-metalsmith-pug's Introduction

Metalsmith Pug

Metalsmith plugin to convert pug files

license release semantic

Install

npm install metalsmith-pug

Usage

I recommend using an optimized build matching your Node.js environment version, otherwise, the standard require would work just fine with any version of Node >= v4.0 .

/*
 * Node 7
 */
const metalsmith-jade = require('metalsmith-jade/lib/node7')

/*
 * Node 6
 */
const metalsmith-jade = require('metalsmith-jade/lib/node6')

/*
 * Node 4 (Default)
 * Note: additional ES2015 polyfills may be required
 */
var metalsmith-jade = require('metalsmith-jade')

API

Pass options to the pug plugin and pass it to Metalsmith with the use method:

import Metalsmith from 'metalsmith'
import pug from 'metalsmith-pug'

const options = {
  pretty: false,

  locals: {
    postName: 'good post name'
  },

  filters: {
    foo: block => block.replace('foo', 'bar')
  }
}

new Metalsmith(__dirname)
  .use(pug(options))

CLI

You can also use the plugin with the Metalsmith CLI by adding a key to your metalsmith.json file:

{
  "plugins": {
    "metalsmith-pug": {
      "pretty": false
    }
  }
}

All options are passed directly to pug. If options has a locals key, that will be passed along to pug.

Options

any of the options parameters for pug with the additional plugin specific properties below:

Name Type Required Default Details
useMetadata Boolean false Expose Metalsmith's global metadata to the pug template
locals Object {} Pass additional locals to the template
filters Object {} register functions to be used as template filters

Author: Ahmad Nassri • Twitter: @AhmadNassri

node-metalsmith-pug's People

Contributors

ahmadnassri avatar dependabot[bot] avatar greenkeeperio-bot avatar ianstormtaylor avatar kmiyashiro avatar kylepaulsen avatar maxbareiss avatar renovate-bot avatar shimbaco avatar surgo avatar sventschui avatar wspringer avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

node-metalsmith-pug's Issues

Errors are not passed to metalsmith's done callback

I just realized, that if one file errors, because of wrong pug syntax like:

.correct

buggy*line/throws

This error is not properly handled and passed to done callback, instead it is just ignored...

It is very important to propagate the error so that one could handle it by:

metalsmith.build((err) => {
  if(err) {
    // handle it here
    return
  }
})

Refer to the docs about proper error handling in Node:

Pug is out of date

I'm getting a warning on my repo because metailsmith-pug is using a vulnerable version of pug. Can we upgrade to version 3?

I tried to do this but I couldn't figure out how this repo generates the output file. Running npm run compile doesn't seem to create a lib directory.

Files 'own data' is leaking to the next compiled file

First I like to say thank you for a nice work! Second I would like to say that there is a possibility that i might have misunderstood the concept of what I considered a bug. Thanks for your help!

Problem

If you have two files (one.jade, two.jade) looking like following
_one.jade_


---
title: file one
someValue: true

---
p file one

_two.jade_


---
title: file two

---
p file two
p= someValue

The _someValue_ will be true in _two.jade_.
My expectation was that file data should be isolated to the current rendering file.

Solution

Line 45 in index.js

// also use the file's own data
if (opts.useMetadata) {
    fileLocals = util._extend(util._extend({}, opts.locals), data);   
}

Line 58 in index.js

// render
var str = jade.compile(data.contents.toString(), opts)(fileLocals)

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:angularmaterial). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Using metalsmith-pug and metalsmith-include to include rendered source files using pug

Hello. I'm using your metalsmith-pug plugin in combination with metalsmith-include to include markdown files in the source directory (which use pug). But I seem to be having an issue with it.

I know that you aren't supporting metalsmith-include, but I'm not sure which of the two plugins is having the problem, so I opened a ticket in metalsmith-include as well.

If you look at the example shown in the metalsmith-include README content, it very similar to what I'm trying to accomplish. The home.md loads home.jade as the template, then it includes thanks.md, assigning it to thanks. Then you can see that the thanks.md file sets the template to thanks.jade. Then thanks.jade just outputs contents (rendered content of home.md) and thanks (rendered content of thanks.md).

The only main difference I can see between that example and my code, is that I'm using pug instead of jade (which I know, same thing)

The problem I'm having, is I cant get the .md file that's getting used as an included file to actually render the content using the template configured in the .md file..

Any idea why the includes would be including the content from the markdown files, but not the rendered pug template?

I created a temporary git repository that will show you the exact issue i'm running into.

Thanks!

Dependency deprecation warning: codeclimate-test-reporter (npm)

On registry https://registry.npmjs.org/, the "latest" version (v0.5.1) of dependency codeclimate-test-reporter has the following deprecation notice:

codeclimate-test-reporter has been deprecated in favor of our new unified test-reporter. Please visit https://docs.codeclimate.com/docs/configuring-test-coverage for details on setting up the new test-reporter.

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Affected package file(s): package.json

If you don't care about this, you can close this issue and not be warned about codeclimate-test-reporter's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

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.