Nanometer Process Machine

    evaluable-tag

    0.0.8 • Public • Published

    evaluable-tag

    The tag has evaluable attribute and it behaves like annotation to next sibling.

    install

    npm install evaluable-tag

    usage

    in browser

    <script src="browser/et.js"></script>
    <script>
      var ET = require('evaluable-tag');
    </script> 

    in browserify

    var ET = require('evaluable-tag');

    ET.evalBy

    html

    <span class="et" data-eval="1 + 2">sum</span>

    javascript

    var evaluated = ET.evalBy('.et');
     
    var et = evaluated[0];
    console.log(et.result); // 3
    console.log(et.annotation.textContent); // sum
    console.log(et.annotated.textContent); // sum

    ET.evalAnnotationsBy

    html

    <span class="et-a" data-eval="1 + 2">sum</span>
    <div>content</div>

    javascript

    var annotated = ET.evalAnnotationsBy('.et-a');
     
    var et = annotated[0];
    console.log(et.result); // 3
    console.log(et.annotation.textContent); // sum
    console.log(et.annotated.textContent); // content

    The .et-a element visibility become hidden after calling evalAnnotationsBy.

    Install

    npm i evaluable-tag

    DownloadsWeekly Downloads

    3

    Version

    0.0.8

    License

    MIT

    Last publish

    Collaborators

    • all-user