Skip to content

Instantly share code, notes, and snippets.

@gavinmcfarland
Last active September 25, 2019 21:20
Show Gist options
  • Select an option

  • Save gavinmcfarland/c6251ff28f4c93d12fd464b046f2ccea to your computer and use it in GitHub Desktop.

Select an option

Save gavinmcfarland/c6251ff28f4c93d12fd464b046f2ccea to your computer and use it in GitHub Desktop.
Experimenting with a Markdown component in Marko
<Markdown># Hello ${input.name}</Markdown>
import marked from 'marked'
class {
onCreate() {
this.state = { content: null };
}
onInput() {
this.state.content = null;
}
recalculate() {
if (this.state.content === null) {
this.state.content = marked(this.getEl("container").textContent);
}
}
onMount() {
this.recalculate();
}
onUpdate() {
this.recalculate();
}
}
<div.wrapper key="container" style={
visibility: state.content ? "unset" : "hidden"
}>
<if(state.content)>$!{state.content}</if>
<else>
<${input.renderBody}/>
</else>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment