0

Handlebar template:

<script id="address_template" type="text/x-handlebars-template">
    <fieldset class="form-fieldset">
        <div class="form-row form-row--half">
            \{{#each fields}}
                \{{{dynamicComponent 'components/common/forms'}}}
                <!-- I also tried `fieldType` instead of `dynamicComponent` -->
            \{{/each}}
        </div>
    </fieldset>
</script>

In above code forms is a stencil component.

Handlebar script:

<script type="text/javascript">
    var template = $("#address_template").html();
    var compiledCode = Handlebars.compile(template);
    var result = compiledCode({fields: state.data.getShippingAddressFields()});
    $('body').html(result);
</script>

Error:

Missing helper: "dynamicComponent""

How to register forms component?

Thomas
  • 8,426
  • 1
  • 25
  • 49
Alex Brend
  • 61
  • 1
  • 8

1 Answers1

1

I'm a bit confused on what the code is supposed to be doing here. In Stencil, you don't need to create your own Handlebars templates as the compilation is all handled server-side. Are you not working within the standard flow of the files?

dynamicComponent is a helper that loops through files within a specified folder, finds the file that matches the "partial" value for the object, and renders out the object with that file. The way you have it set up looks correct, assuming you have a folder "forms" inside templates/components, and this folder has several HTML files in it.

Matt Coy
  • 1,031
  • 2
  • 5
  • I want to create a custom checkout, so all the content i want to display after page loading. So i want to use ready mate component instead of creating new layout. Here i want to display ready mate address from after page loading using JS/jQuery. – Alex Brend Oct 20 '21 at 05:45
  • What is ready mate? – Matt Coy Oct 20 '21 at 14:01
  • Default bigcommerce stencil component like components/common/forms/* – Alex Brend Oct 21 '21 at 05:19
  • I don't think the way you are going about it will work. If you want to get address info on the order confirmation page, you can use the Storefront Checkout API: https://developer.bigcommerce.com/api-docs/storefront/overview – Matt Coy Oct 21 '21 at 13:13