Node.js template with a breath of fresh air
After this release, there will be no need of the edge-supercharged
plugin. However, this version works only with Node@20, because we use the readDirSync.recursive
option that was added in [email protected].
Full Changelog: https://github.com/edge-js/edge/compare/v6.0.0-2...v6.0.0-3
This release contains some breaking changes, but alongside a migration plugin that makes Edge 6 works like Edge 5.
let
tag. Let tag can be used for adding inline variables. It is a replacement for the existing @set
tag.assign
tag to re-assign value to a pre-existing variable.eval
tag to evaluate JavaScript expressions without writing their result to the output.layouts
and sections
. They were badly implemented, and components serve as a better mental model for implementing layouts.set
tag. Instead, use the let
tag. Learn more
You can get the newer version of Edge 6 to work like Edge 5 by registering the following plugin. AdonisJS will include this plugin by default.
import { migrate } from 'edge.js/plugins/migrate'
edge.use(migrate)
The components props have been changed completely, and methods like serialize
and serializeExcept
no longer exist. Instead, you can use the toAttrs
method.
Note: The compatibility plugin allows using the old API
- $props.serialize()
- $props.serializeExcept(['text'])
- $props.serializeOnly(['class'])
+ $props.toAttrs()
+ $props.except(['text']).toAttrs()
+ $props.only(['class']).toAttrs()
set
tag in favor let
tag.The set
tag was complex, as it did too many things together. You can use it to define an inline variable, update its value, and update the property of an existing object.
We have removed it in favor of the let
tag. The let
tags work exactly as JavaScript let
declaration. You can also use the let
tag to destructure values, which was impossible with the set
tag. For example:
- @set('username', user.username)
+ @let(username = user.username)
+ @let({ username } = user)
Re-assigning value to an existing variable
- @set(user, 'username', user.username.toUpperCase())
+ @assign(user.username = user.username.toUpperCase())
For more complex operations, you can use the eval
tag.
@eval(user.users.push(newUser()))
@eval(user.users = user.users ? user.users.concat(newUser()) : [newUser()])
raise
method. It was never documented and neither used.e
method in favor of html.escape
.stringify
method in favor of js.stringify
.safe
method in favor of html.safe
.https://github.com/poppinss/edge/compare/v6.0.0-1...v6.0.0-2
https://github.com/poppinss/edge/compare/v6.0.0-0...v6.0.0-1
toSentence
and ordinalize
are now called sentence
and ordinal
Full Changelog: https://github.com/edge-js/edge/compare/v5.5.0...v5.5.1
The Edge.onRender
method will allow to hook into the renderer instance and maybe share local variables before any template gets rendered.
edge.onRender((renderer) => {
renderer.share({ key: value })
})
Full Changelog: https://github.com/edge-js/edge/compare/v5.3.7...v5.4.0
Full Changelog: https://github.com/edge-js/edge/compare/v5.3.5...v5.3.6