Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

njet-routing-swig

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

njet-routing-swig

Swig extension for njet-routing providing url generator from njet router

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

njet-routing-swig Build Status

Swig extension for njet-routing

To extend swig templates with Your router simply install extension:

npm install njet-routing-swig

After that extend Your swig with njet-routing url generator:

var swig = require('swig'),
    njetRouting = require('njet-routing'),
    njetRoutingSwig = require('njet-routing-swig'),
    router = njetRouting.createRouter();

njetRoutingSwig.addFunctions(swig, router);

whis will add "url" object with methods that match verbs:

  • get
  • post
  • put
  • delete
  • options
  • head
  • trace
  • connect
  • any

Now you can add some route:

router.post.add('create_user', '/api/user/{username}');

And from now you can use it to generate url in template:

var content = swig.render('test: {{ _ext.url.post("create_user", { username: "dariuszp", "new": 1, age: 26 }, true) }}');

This will generate:

test: http://localhost/api/user/dariuszp?age=26&new=1

In case "url" extension is already in your project, just provide option that will overwrite that name to something else:

njetRoutingSwig.addFunctions(swig, router, {
    url: 'sparta'
});

And you can call Your spartans:

var content = swig.render('test: {{ _ext.sparta.post("create_user", { username: "dariuszp", "new": 1, age: 26 }, true) }}');

For more informations about njet-routing visit: https://github.com/dariuszp/njet-routing

Enjoy!

Keywords

FAQs

Package last updated on 17 Mar 2014

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