open-index/open-npm huggingface dataset:
npm package: @startupjs/pug-lexer
Description: The pug lexer (takes a string and converts it to an array of tokens)
Author: ForbesLindesay
Latest version: 4.1.0-1

# pug-lexer

The pug lexer.  This module is responsible for taking a string and converting it into an array of tokens.

[![Build Status](https://img.shields.io/travis/pugjs/pug-lexer/master.svg)](https://travis-ci.org/pugjs/pug-lexer)
[![Dependencies Status](https://david-dm.org/pugjs/pug/status.svg?path=packages/pug-lexer)](https://david-dm.org/pugjs/pug?path=packages/pug-lexer)
[![DevDependencies Status](https://david-dm.org/pugjs/pug/dev-status.svg?path=packages/pug-lexer)](https://david-dm.org/pugjs/pug?path=packages/pug-lexer&type=dev)
[![NPM version](https://img.shields.io/npm/v/pug-lexer.svg)](https://www.npmjs.org/package/pug-lexer)
[![Coverage Status](https://img.shields.io/codecov/c/github/pugjs/pug-lexer.svg)](https://codecov.io/gh/pugjs/pug-lexer)

## Installation

    npm install pug-lexer

## Usage

```js
var lex = require('pug-lexer');
```

### `lex(str, options)`

Convert Pug string to an array of tokens.

`options` can contain the following properties:

- `filename` (string): The name of the Pug file; it is used in error handling if provided.
- `plugins` (array): An array of plugins, in the order they should be applied.

```js
console.log(JSON.stringify(lex('div(data-foo="bar")', {filename: 'my-file.pug'}), null, '  '))
```

```json
[
  {
    "type": "tag",
    "line": 1,
    "val": "div",
    "selfClosing": false
  },
  {
    "type": "attrs",
    "line": 1,
    "attrs": [
      {
        "name": "data-foo",
        "val": "\"bar\"",
        "escaped": true
      }
    ]
  },
  {
    "type": "eos",
    "line": 1
  }
]
```

### `new lex.Lexer(str, options)`

Constructor for a Lexer 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 used in error handling if provided.
- `interpolated` (boolean): if the Lexer is created as a child lexer for inline tag interpolation (e.g. `#[p Hello]`). Defaults to `false`.
- `startingLine` (integer): the real line number of the first line in the input. It is also used for inline tag interpolation. Defaults to `1`.
- `plugins` (array): An array of plugins, in the order they should be applied.

## License

  MIT
npm package: @startupjs/pug-uses-variables
Description: Extract variables from pug template
Author: Eugene Zhlobo
Latest version: 3.0.1-0

# pug-uses-variables [![circleci](https://circleci.com/gh/ezhlobo/pug-uses-variables/tree/master.svg)](https://circleci.com/gh/ezhlobo/pug-uses-variables/tree/master)

Find all JavaScript variables used in pug template.

## Usage

```
$ npm install --save pug-uses-variables
```

```js
const { findVariablesInTemplate } = require('pug-uses-variables')

const pugTemplate = `

  ReactComponent(property=object[item])
    = content

    if condition === matcher
      p Truthy

`.trimRight()

const variables = findVariablesInTemplate(pugTemplate)
```
```js
// `variables` is equal:
[{
  value: 'ReactComponent',
  loc: {
    start: { line: 3,  column: 2 },
    end:   { line: 3,  column: 14 }
  }
}, {
  value: 'object',
  loc: {
    start: { line: 3,  column: 24 },
    end:   { line: 3,  column: 30 }
  }
}, {
  value: 'item',
  loc: {
    start: { line: 3,  column: 31 },
    end:   { line: 3,  column: 35 }
  }
}, {
  value: 'content',
  loc: {
    start: { line: 4,  column: 4 },
    end:   { line: 4,  column: 11 }
  }
}, {
  value: 'condition',
  loc: {
    start: { line: 6,  column: 5 },
    end:   { line: 6,  column: 14 }
  }
}, {
  value: 'condition',
  loc: {
    start: { line: 6,  column: 19 },
    end:   { line: 6,  column: 26 }
  }
}]
```

**Important**: templates should be right-trimmed. Usually it means that you have to execute `.trimRight` on your template-string as in the example above.

### Get variable names only

```js
const variableNames = variables.map(variable => variable.value)
// > ['ReactComponent', 'object', 'item', 'content', 'condition', 'matcher']
```

## Value

This plugin helps us to integrate [babel-plugin-transform-react-pug](https://github.com/pugjs/babel-plugin-transform-react-pug) and [eslint](http://eslint.org).

## Development

* `yarn test`
* `yarn lint`

## License

[MIT](https://tldrlegal.com/license/mit-license)