assemble.io partial pass data to nested partials





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I am using assemble.io and I would want to modularize everyhing using the "atomic design" principles.



Let's say that I start with a couple of single atoms



atomic partial "title" (a-h2-title.html)



<h2 class="{{additionalclasses}}">{{title}}</h2>


atomic partial "info text" (a-info-text.html)



<div class="info {{additionalclasses}}">
{{{text}}}
</div>


As far as I have understood, if I want to use "instances" of these generic components with some data I can define them in a json file like in this example:



info-text-example1.html



{{>a-info-text info-text-example1}}


info-text-example1.json



{
"text":"<p>some text</p>",
"additionalclasses"="info--modified"
}


Ok, now my problem is when I want to define for example a molecule:



m-text-and-title.html



<div class="box {{additionalclasses}}">
{{>a-h2-title}}
{{>a-info-text}}
</div>


Now, if I want an "instance" for this element



text-and-title-example1.html



{{>m-text-and-title ???}}


How can I define all the data for the object itself (additionalclasses) and for the child objects?
I hope I have made myself clear



I've already seen this article here but I am not able to adapt it to my case
Thank you for your answer










share|improve this question





























    1















    I am using assemble.io and I would want to modularize everyhing using the "atomic design" principles.



    Let's say that I start with a couple of single atoms



    atomic partial "title" (a-h2-title.html)



    <h2 class="{{additionalclasses}}">{{title}}</h2>


    atomic partial "info text" (a-info-text.html)



    <div class="info {{additionalclasses}}">
    {{{text}}}
    </div>


    As far as I have understood, if I want to use "instances" of these generic components with some data I can define them in a json file like in this example:



    info-text-example1.html



    {{>a-info-text info-text-example1}}


    info-text-example1.json



    {
    "text":"<p>some text</p>",
    "additionalclasses"="info--modified"
    }


    Ok, now my problem is when I want to define for example a molecule:



    m-text-and-title.html



    <div class="box {{additionalclasses}}">
    {{>a-h2-title}}
    {{>a-info-text}}
    </div>


    Now, if I want an "instance" for this element



    text-and-title-example1.html



    {{>m-text-and-title ???}}


    How can I define all the data for the object itself (additionalclasses) and for the child objects?
    I hope I have made myself clear



    I've already seen this article here but I am not able to adapt it to my case
    Thank you for your answer










    share|improve this question

























      1












      1








      1








      I am using assemble.io and I would want to modularize everyhing using the "atomic design" principles.



      Let's say that I start with a couple of single atoms



      atomic partial "title" (a-h2-title.html)



      <h2 class="{{additionalclasses}}">{{title}}</h2>


      atomic partial "info text" (a-info-text.html)



      <div class="info {{additionalclasses}}">
      {{{text}}}
      </div>


      As far as I have understood, if I want to use "instances" of these generic components with some data I can define them in a json file like in this example:



      info-text-example1.html



      {{>a-info-text info-text-example1}}


      info-text-example1.json



      {
      "text":"<p>some text</p>",
      "additionalclasses"="info--modified"
      }


      Ok, now my problem is when I want to define for example a molecule:



      m-text-and-title.html



      <div class="box {{additionalclasses}}">
      {{>a-h2-title}}
      {{>a-info-text}}
      </div>


      Now, if I want an "instance" for this element



      text-and-title-example1.html



      {{>m-text-and-title ???}}


      How can I define all the data for the object itself (additionalclasses) and for the child objects?
      I hope I have made myself clear



      I've already seen this article here but I am not able to adapt it to my case
      Thank you for your answer










      share|improve this question














      I am using assemble.io and I would want to modularize everyhing using the "atomic design" principles.



      Let's say that I start with a couple of single atoms



      atomic partial "title" (a-h2-title.html)



      <h2 class="{{additionalclasses}}">{{title}}</h2>


      atomic partial "info text" (a-info-text.html)



      <div class="info {{additionalclasses}}">
      {{{text}}}
      </div>


      As far as I have understood, if I want to use "instances" of these generic components with some data I can define them in a json file like in this example:



      info-text-example1.html



      {{>a-info-text info-text-example1}}


      info-text-example1.json



      {
      "text":"<p>some text</p>",
      "additionalclasses"="info--modified"
      }


      Ok, now my problem is when I want to define for example a molecule:



      m-text-and-title.html



      <div class="box {{additionalclasses}}">
      {{>a-h2-title}}
      {{>a-info-text}}
      </div>


      Now, if I want an "instance" for this element



      text-and-title-example1.html



      {{>m-text-and-title ???}}


      How can I define all the data for the object itself (additionalclasses) and for the child objects?
      I hope I have made myself clear



      I've already seen this article here but I am not able to adapt it to my case
      Thank you for your answer







      json handlebars.js templating assemble atomic-design






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 4 at 12:11









      Riccardo De ContardiRiccardo De Contardi

      1,201314




      1,201314
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You will still have to create the data structure in a way that you need it, then in the pages or partials pass the values to the sub-partials. So in this case, I think you can use the following pattern:



          text-and-title-example1.html



          {{>m-text-and-title text-and-title-example1}}


          text-and-title-example1.json



          {
          "additionalclasses": "text-and-title--modified",
          "title-example": {
          "title": "some title",
          "additionalclasses": "title-modified"
          },
          "text-example": {
          "text": "<p>some text</p>",
          "additionalclasses": "info--modified"
          }
          }


          Then update the molecule to be this:



          <div class="box {{additionalclasses}}">
          {{>a-h2-title title-example}}
          {{>a-info-text text-example}}
          </div>


          Now this works the same way as your initial example. You have a data object with properties that you've specified, then you pass those properties into the partials that will use them. The "atoms" have generic, reusable properties already and you can change your "molecule" to do the same... like change title-example to title and text-example to text, but keep them as objects that are passed down to the "atoms".






          share|improve this answer



















          • 1





            your explanation is working and great; I'll just have to think about a good "naming convention" for all the files involved:) I'm accepting it. Thank you!

            – Riccardo De Contardi
            Jan 7 at 8:44












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54038742%2fassemble-io-partial-pass-data-to-nested-partials%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You will still have to create the data structure in a way that you need it, then in the pages or partials pass the values to the sub-partials. So in this case, I think you can use the following pattern:



          text-and-title-example1.html



          {{>m-text-and-title text-and-title-example1}}


          text-and-title-example1.json



          {
          "additionalclasses": "text-and-title--modified",
          "title-example": {
          "title": "some title",
          "additionalclasses": "title-modified"
          },
          "text-example": {
          "text": "<p>some text</p>",
          "additionalclasses": "info--modified"
          }
          }


          Then update the molecule to be this:



          <div class="box {{additionalclasses}}">
          {{>a-h2-title title-example}}
          {{>a-info-text text-example}}
          </div>


          Now this works the same way as your initial example. You have a data object with properties that you've specified, then you pass those properties into the partials that will use them. The "atoms" have generic, reusable properties already and you can change your "molecule" to do the same... like change title-example to title and text-example to text, but keep them as objects that are passed down to the "atoms".






          share|improve this answer



















          • 1





            your explanation is working and great; I'll just have to think about a good "naming convention" for all the files involved:) I'm accepting it. Thank you!

            – Riccardo De Contardi
            Jan 7 at 8:44
















          0














          You will still have to create the data structure in a way that you need it, then in the pages or partials pass the values to the sub-partials. So in this case, I think you can use the following pattern:



          text-and-title-example1.html



          {{>m-text-and-title text-and-title-example1}}


          text-and-title-example1.json



          {
          "additionalclasses": "text-and-title--modified",
          "title-example": {
          "title": "some title",
          "additionalclasses": "title-modified"
          },
          "text-example": {
          "text": "<p>some text</p>",
          "additionalclasses": "info--modified"
          }
          }


          Then update the molecule to be this:



          <div class="box {{additionalclasses}}">
          {{>a-h2-title title-example}}
          {{>a-info-text text-example}}
          </div>


          Now this works the same way as your initial example. You have a data object with properties that you've specified, then you pass those properties into the partials that will use them. The "atoms" have generic, reusable properties already and you can change your "molecule" to do the same... like change title-example to title and text-example to text, but keep them as objects that are passed down to the "atoms".






          share|improve this answer



















          • 1





            your explanation is working and great; I'll just have to think about a good "naming convention" for all the files involved:) I'm accepting it. Thank you!

            – Riccardo De Contardi
            Jan 7 at 8:44














          0












          0








          0







          You will still have to create the data structure in a way that you need it, then in the pages or partials pass the values to the sub-partials. So in this case, I think you can use the following pattern:



          text-and-title-example1.html



          {{>m-text-and-title text-and-title-example1}}


          text-and-title-example1.json



          {
          "additionalclasses": "text-and-title--modified",
          "title-example": {
          "title": "some title",
          "additionalclasses": "title-modified"
          },
          "text-example": {
          "text": "<p>some text</p>",
          "additionalclasses": "info--modified"
          }
          }


          Then update the molecule to be this:



          <div class="box {{additionalclasses}}">
          {{>a-h2-title title-example}}
          {{>a-info-text text-example}}
          </div>


          Now this works the same way as your initial example. You have a data object with properties that you've specified, then you pass those properties into the partials that will use them. The "atoms" have generic, reusable properties already and you can change your "molecule" to do the same... like change title-example to title and text-example to text, but keep them as objects that are passed down to the "atoms".






          share|improve this answer













          You will still have to create the data structure in a way that you need it, then in the pages or partials pass the values to the sub-partials. So in this case, I think you can use the following pattern:



          text-and-title-example1.html



          {{>m-text-and-title text-and-title-example1}}


          text-and-title-example1.json



          {
          "additionalclasses": "text-and-title--modified",
          "title-example": {
          "title": "some title",
          "additionalclasses": "title-modified"
          },
          "text-example": {
          "text": "<p>some text</p>",
          "additionalclasses": "info--modified"
          }
          }


          Then update the molecule to be this:



          <div class="box {{additionalclasses}}">
          {{>a-h2-title title-example}}
          {{>a-info-text text-example}}
          </div>


          Now this works the same way as your initial example. You have a data object with properties that you've specified, then you pass those properties into the partials that will use them. The "atoms" have generic, reusable properties already and you can change your "molecule" to do the same... like change title-example to title and text-example to text, but keep them as objects that are passed down to the "atoms".







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 6 at 17:21









          doowbdoowb

          2,9011221




          2,9011221








          • 1





            your explanation is working and great; I'll just have to think about a good "naming convention" for all the files involved:) I'm accepting it. Thank you!

            – Riccardo De Contardi
            Jan 7 at 8:44














          • 1





            your explanation is working and great; I'll just have to think about a good "naming convention" for all the files involved:) I'm accepting it. Thank you!

            – Riccardo De Contardi
            Jan 7 at 8:44








          1




          1





          your explanation is working and great; I'll just have to think about a good "naming convention" for all the files involved:) I'm accepting it. Thank you!

          – Riccardo De Contardi
          Jan 7 at 8:44





          your explanation is working and great; I'll just have to think about a good "naming convention" for all the files involved:) I'm accepting it. Thank you!

          – Riccardo De Contardi
          Jan 7 at 8:44




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54038742%2fassemble-io-partial-pass-data-to-nested-partials%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas