Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en">
<head>
  <meta charset="UTF-8">
  <title>JSX Alternative to Render Virtual DOM</title>
</head>
<body>
  <h1>HTML to GlueDOM conversion</h1>
  <textarea id="html" class="editor"></textarea>
  <textarea id="glue-dom" class="editor"></textarea>
  <iframe id="parser" src="javascript:void(0)" style="display:none"></iframe>
  
  
  
  <br><br><br>
  <p>Repo: <a href="https://github.com/gluecodes/gluecodes-glue-dom" target="_blank">README.md</a></p>
  <p>If you like it and want to get updated follow me on <a href="https://twitter.com/ChrisCzopp" target="_blank">twitter</a> or <a href="https://dev.to/chrisczopp" target="_blank">dev.to</a></p>
  <p>Do you want to play with a tool which lets you code web apps with HTML and spits out the presented syntax? Visit <a href="https://ide.glue.codes" target="_blank">ide.glue.codes</a>.</p>
  <p>Visit <a href="https://www.glue.codes" target="_blank">www.glue.codes</a> for more.</p>
</body>
</html>
              
            
!

CSS

              
                .editor {
  min-width: 800px;
  min-height: 500px;
}

              
            
!

JS

              
                const parserNode = document.querySelector('#parser')
const htmlNode = document.querySelector('#html')
const glueDomNode = document.querySelector('#glue-dom')

const parseHtml = nodeToParse => (
  parseDomElements({
    domElements: [nodeToParse],
    settings: {
      transformVisualContent: false
    }
  })[0]
)

const wrapHtmlInTestSlot = html => `
  <div gc-as="slot" gc-name="testSlot">${html}</div>
`.trim()

const transformGeneratedAst = (ast) => {
  const filteredAst = ast.body
    .find(node => node.type === 'ExportDefaultDeclaration')
    .declaration
    .body
  
  filteredAst.callee = {
    type: 'Identifier',
    name: 'tag'
  }
  
  return filteredAst
}

const testHtml = `
<div class="card" style="width: 18rem;">
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="card-link">Card link</a>
    <a href="#" class="card-link">Another link</a>
  </div>
</div>
`

htmlNode.value = testHtml.trim()
parserNode.contentDocument.body.innerHTML = wrapHtmlInTestSlot(testHtml)

document.querySelector('#html').addEventListener('keyup', (e) => {
  parserNode.contentDocument.body.innerHTML = wrapHtmlInTestSlot(e.target.value)
  
  const { ast } = parseHtml(parserNode.contentDocument.body.firstChild)

  glueDomNode.value = generateCode(transformGeneratedAst(ast)).code
})

const { ast } = parseHtml(parserNode.contentDocument.body.firstChild)

glueDomNode.value = generateCode(transformGeneratedAst(ast)).code

              
            
!
999px

Console