Skip to content

Instantly share code, notes, and snippets.

@aziis98
Last active June 18, 2018 21:38
Show Gist options
  • Select an option

  • Save aziis98/ea20f0c6a67ef27f34728d557038ea50 to your computer and use it in GitHub Desktop.

Select an option

Save aziis98/ea20f0c6a67ef27f34728d557038ea50 to your computer and use it in GitHub Desktop.
Node = {
Name = "Trim content"
// Tells the editor in which context this node can be used (in this case in a JS-targeted file)
Context = Javascript/Node
Inputs = {
contents = Text
mode = {
type = "Left", "Right", "Both"
default = "Both"
}
}
Outputs = {
text = Text
}
// The following text between :{ ... }: is interpreted as long form text
Fragment = :{
function (contents, mode) {
if (mode === "Both") {
return contents.trim();
}
else if (mode === "Left") {
return contents.trimLeft();
}
else if (mode === "Right") {
return contents.trimRight();
}
else {
throw 'Invalid mode: ' + mode;
}
}
}:
}

Test Node

This is a test Node for my Fragment editor, at the moment the format is just a prototype (still better than JSON for what I prefer).

The format

  • Node.Name required
  • Node.Context required (maybe also a list of valid contextes)
  • Node.Inputs required
  • Node.Outputs required
  • Node.(Inputs|Outputs).[property name] = [type of property]
  • Node.(Inputs|Outputs).[property name].type required
  • Node.(Inputs|Outputs).[property name].default required
  • Node.Fragment maybe?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment