question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Output file missing JSON data

See original GitHub issue

This is a question/help, I wish I could label it that… I am trying process 1 handlebar template with 1 JSON file. The output file, does not show any of the data from the JSON file. What am I doing wrong?

gulp task:

gulp.task('handlebarsProcess2', function () {
    return gulp
        .src('src/templates/Dreamscape.handlebars')
        .pipe(hb({
            data: 'src/data/dreamscape_data.json'

        }))
        .pipe(concat('templates-processed2.html'))
        .pipe(gulp.dest('build'));
});

Template before:

<div id="Dreamscape{{id}}" class="hello">
    {{#projs}}
        <div id="itemNumber{{id}}" tabindex="0" class="porthole {{addClass}}" style="background:{{bkgd}}">{{id}}</div>
    {{/projs}}
</div>

Template processed/output file:

<div id="Dreamscape" class="hello">
</div>

JSON file:

{
    "id":"myIDHere",
    "projs": [
        {
            "id": "home",
            "addClass": "Home"
        },
        {
            "id": "sec1",
            "addClass": "One"
        }
    ]
}

Thanks for the help.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shannonmoellercommented, Mar 29, 2015

Version 2.0 of gulp-hb introduced a breaking change for the data attribute. It’s now using require-glob to pull in data which takes filenames into account. Try updating your template to include the filename (without the extension) of your data, like so:

<div id="Dreamscape{{dreamscape_data.id}}" class="hello">
    {{#each dreamscape_data.projs}}
        <div id="itemNumber{{id}}" tabindex="0" class="porthole {{addClass}}" style="background:{{bkgd}}">{{id}}</div>
    {{/each}}
</div>

Or wrap it in a {{#with}} block:

{{#with dreamscape_data}}
    <div id="Dreamscape{{id}}" class="hello">
        {{#projs}}
            <div id="itemNumber{{id}}" tabindex="0" class="porthole {{addClass}}" style="background:{{bkgd}}">{{id}}</div>
        {{/projs}}
    </div>
{{/with}}
0reactions
shannonmoellercommented, Aug 7, 2018

gulp-hb is a gulp wrapper around handlebars-wax which has a section on registering data. I think it would be better to update the documentation in that README and leave this one pretty generic. Feel free to open an issue or PR over there. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing JSON option at Data > New query > From File
There is an easy workaround. Go to Data Tab on Ribbon and follow these steps: 1 ...
Read more >
JSON data missing while sending to server - Stack Overflow
try using the following con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");. Example
Read more >
JSON output has some data missing · Issue #280 - GitHub
I am using the demo http://oss.sheetjs.com/js-xlsx with attached file. The CSV output looks right, but JSON output has only data for first column...
Read more >
Data Processor not returning any data for valid JSON
303179~1595518588~~InputFromBuffer%Missing a colon after a name of object ... web consumer transformation (Output XML) to a Data processor transformation.
Read more >
Resolve JSON errors in Amazon Athena - AWS
Resolution · Use the correct JSON SerDe · Use one line per record · Use the correct data type in each column ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found