sails-hook-meta
Sails extension for generating meta header.
Installation
$ npm install sails-hook-meta
Usage
Upon installation, a meta object will be added to req.
//-- api/controllers/HomeController.jsmoduleexports = { reqmeta; res; }; //-- views/home/index.ejs<html> <head> <%- reqmeta %> </head></html> //-- output<html> <head> <meta name="title" content="Page Title"> </head></html>
Methods
set(attrs)
Returns true if meta attributes are successfully set. Returns false otherwise. The parameter attrs could be an Object or array of Objects. This function tries to keep the meta items unique by looking at primary attributes. Currently, it only checks for name, property, http-equiv and charset values for uniqueness.
reqmeta;reqmeta;reqmeta; reqmeta;
add(attrs)
Similar to set() except that this function doesn't check for uniqueness.
reqmeta;reqmeta;reqmeta; reqmeta;
remove(attrs)
Returns true if meta item/s is successfully removed. Returns false otherwise.
reqmeta;reqmeta;
clear()
Deletes all meta items.
reqmetaclear;
toString()
Returns the meta markup string.
// req.meta.set({ charset: "utf-8" });// req.meta.set({ "http-equiv": "refresh", content: "30" }); reqmeta; // <meta charset="utf-8">// <meta http-equiv="refresh" content: "30">
toJSON()
Returns the array of meta objects.
// req.meta.set({ charset: "utf-8" });// req.meta.set({ "http-equiv": "refresh", content: "30" }); reqmeta; // [ { charset: "utf-8" }, { "http-equiv": "refresh", content: "30" } ]