Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assemble issue with inline partial used with condition #937

Open
monty2610 opened this issue Sep 18, 2017 · 3 comments
Open

Assemble issue with inline partial used with condition #937

monty2610 opened this issue Sep 18, 2017 · 3 comments

Comments

@monty2610
Copy link

monty2610 commented Sep 18, 2017

version

0.24.3

HI We are migrating our grunt assemble to gulp. But getting some issues

  1. inline partials are not working when used inside if helper. It works if inline partial used without condition
  2. For some pages node running out of memory occurs.

error message

For inline partials inside condition, getting following error

Stack:
Error: The partial collapseButton could not be found
    at Object.invokePartial (D:\XT-webpack\kairos_xt_presentation\node_modules\assemble\node_modules\handlebars\dist\cjs\handlebars\runtime.js:281:11)
    at Object.handlebars.VM.invokePartial (D:\XT-webpack\kairos_xt_presentation\node_modules\assemble\node_modules\engine-handlebars\index.js:196:26)
    at Object.invokePartialWrapper [as invokePartial] (D:\XT-webpack\kairos_xt_presentation\node_modules\assemble\node_modules\handlebars\dist\cjs\handlebars\ru
ntime.js:68:39)
    at eval (eval at createFunctionContext (D:\XT-webpack\kairos_xt_presentation\node_modules\assemble\node_modules\handlebars\dist\cjs\handlebars\compiler\java
script-compiler.js:254:23), <anonymous>:6:28)
    at Object.prog [as fn] (D:\XT-webpack\kairos_xt_presentation\node_modules\assemble\node_modules\handlebars\dist\cjs\handlebars\runtime.js:221:12)
    at Object.<anonymous> (D:\XT-webpack\kairos_xt_presentation\node_modules\assemble\node_modules\handlebars\dist\cjs\handlebars\helpers\if.js:19:22)
    at Object.<anonymous> (D:\XT-webpack\kairos_xt_presentation\node_modules\deep-bind\index.js:61:15)
    at D:\XT-webpack\kairos_xt_presentation\node_modules\async-helpers\index.js:347:23
    at D:\XT-webpack\kairos_xt_presentation\node_modules\async-helpers\node_modules\co\index.js:136:8
    at thunkToPromise (D:\XT-webpack\kairos_xt_presentation\node_modules\async-helpers\node_modules\co\index.js:135:10)
    at toPromise (D:\XT-webpack\kairos_xt_presentation\node_modules\async-helpers\node_modules\co\index.js:119:55)
    at next (D:\XT-webpack\kairos_xt_presentation\node_modules\async-helpers\node_modules\co\index.js:99:29)
    at onFulfilled (D:\XT-webpack\kairos_xt_presentation\node_modules\async-helpers\node_modules\co\index.js:69:7)
    at process._tickCallback (internal/process/next_tick.js:109:7)

Here is the test partial

<div class="mol_partial_view_toggle{{#if typeString}} {{typeString}}{{/if}}" data-component="mol_partial_view_toggle" {{#if id}}id="{{id}}" {{/if}}>
{{#*inline "collapseButton"}}
  <div>Button</div>
{{/inline}}
{{#if buttonBeforeText}}
  {{>collapseButton}}
{{/if}}
Text
{{#unless buttonAfterText}}
  {{>collapseButton}}
{{/unless}}
</div>

For node running out of memory

<--- Last few GCs --->

  213792 ms: Mark-sweep 1254.7 (1418.5) -> 1254.7 (1418.5) MB, 1260.6 / 0.0 ms [allocation failure] [GC in old space requested].
  215062 ms: Mark-sweep 1254.7 (1418.5) -> 1254.7 (1418.5) MB, 1269.7 / 0.0 ms [allocation failure] [GC in old space requested].
  216317 ms: Mark-sweep 1254.7 (1418.5) -> 1254.7 (1404.5) MB, 1254.3 / 0.0 ms [last resort gc].
  217604 ms: Mark-sweep 1254.7 (1404.5) -> 1254.7 (1404.5) MB, 1286.7 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 00000229C24CFB49 <JS Object>
    1: /* anonymous */ [D:\XT-webpack\kairos_xt_presentation\node_modules\deep-bind\index.js:~45] [pc=000001B9A518F920] (this=0000004ADAD54B01 <an Object with m
ap 0000022328D4DAA9>)
    2: arguments adaptor frame: 2->0
    3: /* anonymous */ [D:\XT-webpack\kairos_xt_presentation\node_modules\async-helpers\index.js:347] [pc=000001B9A5151717] (this=0000034A2338AB69 <JS Global Ob
ject>,cb=0000003...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
// assemblefile.js

gulp.task('assemble-pages', function() {
  // Set main assemble options
  assemble.option('layout', 'default.hbs');
  assemble.helpers('./source/helpers/*.js');
  assemble.partials(['source/templates/components/{,*/}*.hbs',
                     'source/templates/includes/{,*/}*.hbs'
                   ]);
  assemble.layouts('source/templates/layouts/*.hbs');
  assemble.pages('source/templates/components/mol_partial_view_toggle/mol_partial_view_toggle__sample.hbs');
  assemble.data([
            'source/data/*.json'
          ]);

  // push "pages" collection into stream
  return assemble.toStream('pages')
      // render pages with default engine (handlebars)
      .pipe(assemble.renderFile())
      .pipe(flatten())
      .pipe(extname())
      // specify your output
      .pipe(assemble.dest('dist'));
});

edited by @jonschlinkert to wrap code in backticks and try to make code readable

@assemblebot
Copy link

@monty2610 Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

If your issue is related to one of the following, please open an issue there:

  • grunt-assemble Issues with using assemble in grunt or the grunt-assemble library.
  • handlebars-helpers Issues with using handlebars helpers from the handlebars-helpers library.

@doowb
Copy link
Member

doowb commented Sep 20, 2017

@monty2610 I'll take a look at the partial issue when I get a chance.
Does the "out of memory" issue only happen when the partial is used inside a conditional?

@monty2610
Copy link
Author

Hi @doowb Yes I am facing this mainly when using a inline partial inside helper (if, unless, each)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants