New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-ejs

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-ejs

A grunt task for rendering ejs templates.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

grunt-ejs

A Grunt task for compiling ejs templates.

Getting Started

Install this grunt plugin next to your project's Gruntfile.js with: npm install grunt-ejs --save-dev.

Then add this line to your project's Gruntfile.js:

grunt.loadNpmTasks('grunt-ejs');

Documentation

Add the task to your config and specify the destination for the compiled file:

grunt.initConfig({
  ejs: {
    all: {
      src: ['app/**/*.ejs', '!app/partials/**/*'],
      dest: 'dist/',
      expand: true,
      ext: '.html',
    },
  },
});

Passing data/helpers to the templates

Use options to pass data and helpers to the templates:

Gruntfile.js:

grunt.initConfig({
  ejs: {
    all: {
      options: {
        title: 'My Website',
        url: function(url) {
          return 'http://example.com/formatted/url/' + url;
        },
      },
      src: ['app/**/*.ejs', '!app/partials/**/*'],
      dest: 'dist/',
      expand: true,
      ext: '.html',
    },
  },
});

app/index.ejs:

<html>
  <head>
    <title><%= title %></title>
  </head>
  <body>
    <a href="<%= url('home.html') %>">Home Page</a>
  </body>
</html>

Ideally all your helpers and non-app specific config should be another module and merged in like this:

grunt.initConfig({
  ejs: {
    all: {
      options: grunt.util._.merge(require('my-helpers'), {
        title: 'My Website'
      }),
      src: 'index.ejs',
      dest: 'index.html',
    },
  },
});

Release History

  • 1.0.0
    • update ejs to 3.0.2
  • 0.3.0
    • update ejs to 2.2.3
    • fix file options
  • 0.2.0 update ejs to 1.0.0
  • 0.1.0 initial release

License

Copyright (c) 2014 Kyle Robinson Young
Licensed under the MIT license.

Keywords

FAQs

Package last updated on 13 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc