All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Antlers::ComponentCachekeeps what a component rendered for a while. A component class withcache_secondsis made and rendered once for each set of props, locale and context. Later renders reuse its HTML until its time is up. An app sets the context for each request withComponentCache.with_context, like the site it came to.ComponentCache.skip!stops every component rendering now from being kept, for something one visitor should see. Loading translations clears the cache.
- Translation blocks for writing that reads better whole in each language than as separate strings, like a card's text. Each
<{ translation: 'de' }>starts the next language, like an elsif, and one<{ :translation }>closes them all. The visitor's locale renders, or its language for a region likede-AT, or else the first, which is the template's own language. Translations don't nest <{ else: }>in an<{ if: }>starts what shows when its value is false- A node can divide on a segment, starting its next part rather than nesting another inside it, which translation blocks do for each language
Translations.choose(languages)gives which of some languages the current locale reads
- A symbol's text can show values from the template, like
{@email}, so a sentence with a value in it is translated whole. Values are escaped like any other - A locale can translate a symbol by its name, like
de: { receipt_emailed: ... }
Translations.localesis worked out once for each set of translations, rather than on every request
- A template is compiled to Ruby on its first render, like ERB, rather than walking its nodes on every render. HTML, variables, fors and ifs run as plain Ruby, and a for's values are Ruby locals rather than locals set on the binding. Components and other nodes still render themselves. A list of 10 users renders about 4 times faster, with a third of the objects
- Reading a value's path no longer makes a new array for each key
- Each
{expression}is read once and remembered, rather than on every render. A render only looks up the variable, so a page with many values, like a table of 77 rows, renders about a quarter faster
- A
<{ :slot }>inside another component's slot renders what its own component was given. It rendered that slot again until the stack overflowed, like aPagethat passes its slot on inside<{ Layout: }>, or to a plain Ruby class that takesslot:
- Each node rendered inside another renders inside a
NodeEventwhen LowEvent has one. The request's tree then times it with the events it causes
if:treats a blank string, like''or' ', as false, as well asnilandfalse, so<{ if: @user.website }>shows nothing for a field left empty
- Rendering appends each child's output to the block's, where it copied everything rendered so far for every child, so a long
for:loop, like a page's 250 comments, rendered in time that grew with the square of its length
- An end tag that doesn't name its block, like
<{ :if }>, has the name:namelessin the lexer's segments, asLexeme::NAMELESS_END, where it had'level_1'
- A component with a
<{ :slot }>can be used without one, like<{ Card }>, and its slot renders nothing, where it raisedundefined method 'children' for nil
- An
ifinside anif, or aforinside afor, closes with its own end tag, where it closed the outer one and the template didn't parse
- A form's HTML attributes, like
<{ form: '/cart' class='add-to-cart' }>
- Components get the render context of the template they're in
method: 'GET'and anything else after a form's action went into its action, so<{ form: '/search' method: 'GET' }>posted to/search' method: 'GET
- A child node's
RenderEventhas its parent'srequest, when the installed lowevent'sRenderEventtakes one
- Rendering a template takes about a third less time, as the lexer compiles its patterns once, rather than for each part of a template
- Breaking:
PropNodeisSoloNode, and its element and lexeme are:solo, as every node can have props, while a solo node is one without a slot, like<{ Card title='Hi' }> - A lexeme's
match?andlexemeget the directive as it's written, assegment:, so an app can read its own syntax - Breaking:
metadata:iscontext:inAntlers.renderand every node'srender, as it's whatever the app passes down to its nodes
- Escape variables with
CGI.escapeHTMLand drop the erb dependency, which took about 0.3s to load - Breaking: Limit allowed methods on basic types
- Pass params when their parent event has them
- Support translations (
{"Hello"}and{:app_name})
- Identify values like
true,false,nil,:draftwithLowkey::ValueParser
- Support keywords without a value
- Raise error for missing closing tag
- Preserve whitespace
- Support metadata
- Remove hard dependency on lowevent
- Release V1 API
- Support props on slots
- Use plugs gem to manage supported elements
- Support if condition
- Support variables in deerheads syntax
- Make arguments omittable
- Namespace support
- Basic form support
- Pass props to initialize when method is present
- Standardise falling back to a user defined string
- Support key/value iteration of hashes in for loop (
<{ for: key, value in: @items }>) - Support method chain syntax
{ variable.method }
- Introduce for loop (
<{ for: user in: @users }>)
- Rename
Antlers.parsetoAntlers.ast
- Support props
- Support slots
- Support variables
- Add lexer
- Add parser
- Basic template