linkedin / linkedin/dustjs

debug friendly compiler output

Open
#298 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.9k
Forks
461
PR merge metrics
No merged PRs in 30d

Description

I've been running compiled dust templates through beautify.js - and while it makes it much easier to trace, they are still not so easy to debug.

eg,

(a template that makes a button and gets the href from the context { nav : 'http://blarg.com', title : 'Blargh Site!' }

``` javascript
(function() {
dust.register("bigbutton", body_0);
function body_0(chk, ctx) {
return chk
.write(
" ").reference(
ctx.get("title"), ctx, "h").write("
");
}
return body_0;
})();
```

I propose a compiler mode, perhaps dust.compiledebug - which would instead produce this kind of output:

``` javascript
(function() {
dust.register("bigbutton", body_0);
function body_0(chk, ctx) {
var get = {};
chk = chk.write(" ");
get["title"] = ctx.get("title");
chk = chk.reference(get["title"], ctx, "h");
chk = chk.write("
");
return chk;
}
return body_0;
})();
```
- runs beautify.js
- produces more local varaibles
- does not chain calls (eg, chk.write('bla').reference(...).write('bla bla);
- automatically inserts logger statements, perhaps using #137

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the compiler output path and beautify.js, then inspect issue #137 for the proposed logger behavior. A complete change would add a debug compilation mode that emits local variables, avoids chained calls, runs beautification, and defines the expected logger statements.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.