<script type="text/x-red" data-template-name="pegjs">
    <div class="form-row">
        <label for="node-input-grammar"><i class="fa fa-filter"></i> Grammar</label>
        <textarea id="node-input-grammar" placeholder="grammar"></textarea>
    </div>
    <br>
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
        <input type="text" id="node-input-name" style="width:70%">
    </div>
</script>

<script type="text/x-red" data-help-name="pegjs">
    <p>Parse and transform message payload using <a href="https://pegjs.org" >PEG.js</a></p>
    <h3>Inputs</h3>
    <dl class="message-properties">
        <dt>payload <span class="property-type">string</span></dt>
        <dd>the string to parse.</dd>
        <dt class="optional">grammar <span class="property-type">string</span></dt>
        <dd>PEG.js grammar</dd>
    </dl>
    <h3>Output</h3>
    <dl class="message-properties">
        <dt>payload <span class="property-type">string</span></dt>
        <dd>Parser output</dd>
    </dl>
</script>

<script type="text/javascript">
    RED.nodes.registerType('pegjs', {
        category: 'function',
        color: "#DEBD5C",
        defaults: {
            grammar: {value: ""},
            name: {value: ""}
        },
        inputs: 1,
        outputs: 1,
        icon: "pegjs.png",
        label: function () {
            return this.name || this.tag || "pegjs";
        },
        labelStyle: function () {
            return this.name ? "node_label_italic" : "";
        },
    });
</script>