Project

lownode

0.0
The project is in a healthy, maintained state
Flexible building blocks
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.2.1
~> 1.6
 Project Readme

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():

class MyNode < LowNode
  def render
    <p>Hello</p>
  end
end

Antlers

Antlers syntax can be embedded within RBX:

class ParentNode < LowNode
  def render
    <html><{ ChildNode }></html>
  end
end

class ChildNode < LowNode
  def render
    <strong>Hello</strong>
  end
end

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:

def render
  <{ parallelize: }>
    # For Loop executed at the same time as UserNode.
    <{ for: user in: @users }>
      <{ UserNode user=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:

class MyNode < LowNode
  def initialize
    @greeting = 'Hello'
  end

  def render
    <<~HTML
      <p>#{@greeting}</p>
    HTML
  end
end