Skip to content

Repository files navigation

Gem version

LowNode

Low Nodes are the flexible building blocks of your application. They can respond to a route request, or they can be called by another node. They can render a return value, or they can create an event. They are designed to be specific enough to observe events and return values, but generic enough to be split up to represent a complex application with its own patterns and structure.

Nodes can render HTML/JSON directly from the Ruby class (via RBX, similar to JSX) and render other nodes into the output using Antlers syntax; <html><{ ChildNode }></html>.

RBX

Use .rbx as your file extension and now you can place HTML inside of render():

classMyNode < LowNodedefrender
<p>Hello</p>
endend

Antlers

Antlers syntax can be embedded within RBX:

classParentNode < LowNodedefrender
<html><{ChildNode}></html>
endendclassChildNode < LowNodedefrender
<strong>Hello</strong>
endend

Which outputs:

<html><strong>Hello</strong></html>

ℹ️ For the full syntax guide see Antlers.

Parallelism and Immutability

LowNode converts props to immutable copies, allowing you to run sections of code in parallel:

defrender
<{parallelize: }>
# For Loop executed at the same time as UserNode.
<{for: userin: @users}>
<{UserNodeuser=user}>
<{:for}>
# PostsNode executed at the same time as For Loop.
<{PostsNode}>
<{:parallelize}>
end

HTML

Use .rb as your file extension to render using string interpolation:

classMyNode < LowNodedefinitialize@greeting='Hello'enddefrender<<~HTML<p>#{@greeting}</p> HTMLendend

About

Flexible building blocks

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages