How to use the idyll-ast.getNodesByType function in idyll-ast

To help you get started, we’ve selected a few idyll-ast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github idyll-lang / idyll / packages / idyll-cli / src / pipeline / parse.js View on Github external
const parseMeta = ast => {
  // there should only be one meta node
  const metaNodes = getNodesByType(ast, 'meta');

  let metaProperties = {};
  if (metaNodes.length > 1) {
    console.warn('There are more than 1 meta nodes');
  } else if (metaNodes.length === 1) {
    getPropertyKeys(metaNodes[0]).forEach(key => {
      metaProperties[key] = getProperty(metaNodes[0], key).value;
    });
  }
  return metaProperties;
};
github idyll-lang / idyll-studio / src / render / idyll-display / components / deploy.js View on Github external
componentDidMount() {
    // Grab meta node
    let node = idyllAST.getNodesByType(this.context.ast, 'meta')[0];
    this.setState(
      {
        metaNode: node
      },
      () => {
        if (!this.state.metaNode) {
          // if doesn't exist insert into tree
          compile('[meta /]').then(metaAST => {
            let ast = this.context.ast;
            let lastChild = ast.children[ast.children.length - 1];

            // reset ids
            metaAST.children[0].id = getRandomId(); // TextContainer
            this.setState({ metaNode: metaAST.children[0].children[0] }); // meta
            this.state.metaNode.id = getRandomId();
github idyll-lang / idyll-studio / src / render / idyll-display / sidebar / index.js View on Github external
getAllVariables() {
    return AST.getNodesByType(this.context.ast, 'var').map(variable => {
      const props = variable.properties;
      const name = props.name.value;
      const value = props.value.value;
      return (
        <div>
          <li>
            {name}, whose current value is {value}
          </li>
          
        </div>
      );
    });
  }
github idyll-lang / idyll / packages / idyll-cli / src / pipeline / parse.js View on Github external
exports.getDataNodes = ast => {
  const nodes = getNodesByType(ast, 'data');
  return nodes.map(node => {
    return {
      node,
      name: getProperty(node, 'name'),
      source: getProperty(node, 'source')
    };
  });
};