Releases: edge-js/edge
Woohah, tremendous improvements to the inspect helper
In order to print server side objects in the browser, you need to convert them to a string, since you cannot send a Javascript primitives over HTTP.
Many individuals opt for JSON.stringify(someObj)
to convert an object to its string representation and then print it in the browser. In fact, many template engines provides helpers for JSON.stringify
. For example: nunjucks
Problems with JSON.stringify
The stringify
method cannot represent all of the Javascript data types. It includes Maps
, Sets
, BigInt
and so on.
More importantly, the output of JSON.stringify
is not a true representation of an object and can trick you many times. For example:
You have the following class
class User {
constructor() {
this.options = {
timezone: 'UTC',
theme: 'dark'
}
this.attributes = {
username: 'virk',
email: 'virk@adonisjs.com'
}
}
toJSON() {
return this.attributes
}
}
If you print an instance of this class using console.log
, you will get the desired outcome
console.log(new User())
// User {
// options: {
// ...
// },
// attributes: {
// ...
// }
// }
However, with JSON.stringify
, you get the following output.
console.log(JSON.stringify(new User()))
// '{"username":"virk","email":"virk@adonisjs.com"}'
Where are the attributes
and options
properties?
Well, the JSON.stringify
method recursively calls .toJSON
method on the objects you pass. So, when the user
instance it passed to JSON.stringify
method, it returns the output of user.toJSON
.
This is not a problem with JSON.stringify
, since this method is not meant to inspect native data types. It is meant to serialize/deserialize them.
The console.log
method of Node.js doesn't use JSON.stringify
, it uses util.inspect. The util.inspect
method is great for dump the output in a terminal, but not in a browser.
Edge inspect
helper
With this release, the edge inspect helper works similar to console.log/util.inpsect
, but the output is tailored for browser with support for pretty printing.
Usage
Write the following code inside any template file.
{{ inspect(state) }}
Output
Commits
Fixing the inspect output HTML
- fix: inspect output html do not overflow long lines 0055b81
Raise error when super is used outside the section tag
Dream Release
Edge is finally at a stage, where it is super solid and intuitive to use and hence doesn't have feature bloat.
Highlights
- The error tracking is super solid. Compile time and runtime error will point back to the actual source code and not some compiled gibberish.
- Almost every Javascript expression is supported inside Mustache braces.
- Expression inside mustache can be written in multiple lines.
- The components and slots exposes some great ways to create powerful components. Just like vue, you can pass data to slots when using them inside a component.
- The
inspect
helper allows inspecting objects while pretty printing them.
Commits
- improvement: use Jet brains mono for pretty print font fdab49e
- feat: add truncate and excerpt tags eb3a492
- feat: add inspect and safe global methods adb499f
- feat: add safe and inspect globals b6d0b01
- test: fix test helpers to address newlines issue on windows dddb219
- fix: escape filename characters before setting it as filename inside template buffer c6c8e05
- ci: fixing newline helpers for windows tests 9aeffe9
- test: add a test covering \u path issue for windows 6b46aa2
- feat: export types required for creating a tag 453c865
- refactor: remove unused code a993a9d
- chore: remove unused dependencies dd7d843
- chore: update dependencies 02aacb9
- ci: update min node version e57b21b
- test: add more tests for edge cases 9c67e6a
- chore: remove unwanted dependencies 4e86c7d
- refactor: improving the way newlines are handled 86e6d4c
- refactor: fix fixtures after lexer update e97b681
- refactor: remove examples in favor of the new repo dc9f07b
- refactor: remove globals, will move them to separate package 4941949
- refactor: cleanup codebase 0644c41
- feat: add @includeIf tag a8cd83b
- refactor(include tag): do not wrap output inside template literals eed0249
- refactor: finalize @component tag 02abb68
- refactor: complete @set tag b082e67
- refactor: complete @yield tag fb5471f
- feat: finalize @unless tag 9fc5fe5
- refactor: finalize @include tag 202f03b
- refactor: complete @each tag d1a581f
- refactor: finalize @debugger tag 95df053
- refactor: finalize if and else tags 6879174
- refactor: finalize CacheManager API ad4ee7e
- refactor: finalize StringifyObject API f904d79
- refactor: finalize Template API 62a50a6
- refactor: finalize compiler API 46763db
- refactor: finalize Context API 96dec74
- refactor: finalize loader api 17747a4
- chore: update dependencies cca6487
Bunch of improvements and better error tracking
- chore: update dependencies 6af494d
- test: add test case addressing #41 8edfcd8
- test: write test to cover issue #64 fe0d683
- test: add tests for issue #25 6c46e1e
- refactor: adding new global functions 6756713
- style: update example to use youch for rendering errors ec07c45
- feat: runtime errors now points to the actual file and line number 2137d22
- refactor: move extractDiskandTemplateName method to loader e93ed43
- refactor: move sharedState to presenter from context bb4cd29
- refactor: finalize compiler api 33b287b
- refactor: finalize cachemanager api 21ebb45
- feat: add fromAcornAst method to create stringified object from acorn ast expressions 06c1cd6
- refactor: complete stringfiedObject api 689f7fa
- style: remove @module docblock afa64d9
- refactor: finalizing context api and implementation c054fe0
- refactor: finalize loader api and implementation 8aabcc8
- chore: update dependencies 6ca2aee
Share filename with templates runtime and inspect global method
- test: fix breaking tests after last commit 93c6343
- chore(package): update dependencies 40fa757
- feat: add property to context ae5dd79
- feat: add inspect global method 1d6aa75
- feat: add context.safe to mark a value as safe 0ca5991
- feat: add option to view the context state 227fb0a
- chore(package): update dependencies d4f680c
Fixing the tags registration by calling the run method
Tightening things up
- docs(readme): update readme template 38941ce
- chore: fix example 3feccca
- chore(package): update dependencies 9417b60
- refactor: accept an object of options when instantiating edge 4041b38
- chore: update parser c3c69e4
- refactor: improving stack traces for included files, layouts & components 9b72583
- fix(compiler): pass absolute filepath to parser & lexer for appropriate stack trace 4c4300c
Release 2.0.0
Docs will follow soon
- chore: update package name and publish config 1a37192
- chore(package): update depedencies bad7765
- chore(package): update dependencies 3c80cd6
- chore: updgrade parser and make required changes d44fb46
- refactor: update examples code a7c798c
- refactor: define presenter & sharedState on context contract 4530aed
- refactor: improve edge api and cleanup utils c2ffb90
- refactor: cleanup entire project API c2382bc
- refactor: finalize compiler API a0d5502
- chore: setup np for releases 5cc6452
- refactor: cleanup and upgrade to new project style 6c0c405
- chore(package): update dependencies and make required changes as per that 6ec2bd7
- docs(readme): fix docs URl 35089cc
- docs: Fix the NPM package URL d6e4307
- style(utils): cleanup code 1c41b64
- fix(loader): do not make abs path for pre registered templates ca780e5
- chore(package): update dependencies e30e087
- docs(readme): update readme file ad42d9e
- docs(typedoc): add typedoc api docs 3ff9e8a
- fix(edge.render): set state to empty object by default b88f9e8
- refactor(debug): add debug statements bfa4cc4
- feat(layout): implement layouts in the compiler 73d0b39
- refactor(errors): use edge-error for consistent error stacks 4894f4a
- WIP e350e47
- chore(package): add edge-error dependency 418a918
- feat(loader): add support for registering template as a string 761d317
- test(each): set intermediate values inside each loop 1989461
- feat(yield): add yield tag cc4dc87
- test(component): add nested component test 54a5ff1
- refactor(tags): make tags all static f074718
- feat(unless): add unless tag 60b2c0a
- feat(each): add runtime $loop to the each loop 41715b2
- feat(set): add set tag 81dcae8
- feat(debugger): add debugger tag 772cdb7
- test(components): add more tests for components around edge cases d102d75
- feat(components): allow slots to define the prop name themselves aace6d9
- feat(components): components can now pass data to the slots 4edb22e
- feat(edge): add main public interface of edge fd884ea
- feat(loader): add support for presenter in the loader 13c9e97
- refactor(*): cleanup api 4da7acf
- feat(component): implement component tag 01e8e95
- chore(package): update parser 726142a
- feat(tag): each f8d6d02
- feat(tags): implement include tag 79800b9
- test(if): write tests around invalid if syntax 8b2a761
- feat(tags): implement if,elseif and else tags f7647b5
- feat(Template): get first version of template renderer ready e4935eb
- feat(loader): add file system loader cc3aa63
- chore(setup): setup mrm and run all tasks aa10de0
- refactor(*): remove everything b92c7bf
Initial Release
This release contains all the core features of Edge and does not have any notable changes, since this is the 1st time the package has been released