@sujalchoudhari/solaris-ui
Version:
A UI framework to create HTML pages with just JavaScript.
45 lines • 1.32 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const mustache_1 = __importDefault(require("mustache"));
/**
* Atom
* -----
* An atom is a single HTML element with its properties.
* An atom has a template string and the props that are to be rendered in the template.
* @author Sujal Choudhari <sjlchoudhari.gmail.com>
*/
class Atom {
/**
* The template string
*/
template;
/**
* The props that are to be rendered in the template
*/
props;
/**
* Creates a new Atom
* @param template The template string
* @param props The props that are to be rendered in the template
*/
constructor(template, props) {
this.template = template;
this.props = props;
if (this.template !== null)
mustache_1.default.parse(this.template);
}
/**
* Get the HTML equivalent of the atom
* @returns The rendered template string with the props
*/
toString() {
if (this.template === null)
return "";
return mustache_1.default.render(this.template, this.props);
}
}
exports.default = Atom;
//# sourceMappingURL=atom.js.map