UNPKG

jade

Version:

Jade template engine

71 lines (57 loc) 1.06 kB
/*! * Stylus - Literal * Copyright(c) 2010 LearnBoost <dev@learnboost.com> * MIT Licensed */ /** * Module dependencies. */ var Node = require('./node') , nodes = require('./'); /** * Initialize a new `Literal` with the given `str`. * * @param {String} str * @api public */ var Literal = module.exports = function Literal(str){ Node.call(this); this.val = str; }; /** * Inherit from `Node.prototype`. */ Literal.prototype.__proto__ = Node.prototype; /** * Return hash. * * @return {String} * @api public */ Literal.prototype.__defineGetter__('hash', function(){ return this.val; }); /** * Return literal value. * * @return {String} * @api public */ Literal.prototype.toString = function(){ return this.val; }; /** * Coerce `other` to a literal. * * @param {Node} other * @return {String} * @api public */ Literal.prototype.coerce = function(other){ if (other instanceof Literal || other instanceof nodes.Ident) { return other; } else { return Node.prototype.coerce.call(this, other); } };