Search code examples
inlinepartialdust.js

Add a partial inside a partial in Dust


I need to pass values to a dust template in the following manner:

<div class="o-outer">
    {>"atoms/button" text="{+filteredClass/}"/}
</div>

{<filteredClass}
    {@customFilter _key="MENU" /}
{/filteredClass}

Any idea how to achive this?


Solution

  • I think you will want to define a custom filter instead of a helper with a custom filter. See http://www.dustjs.com/docs/filter-api/ for details on how to create a custom filter. Then you will be able to do:

    <div class="o-outer">
        {>"atoms/button" text="{text|myFilter}"/}
    </div>
    

    This all assumes that your customFilter helper is actually being used in the same way that Dust filters are used. If not, then you will probably need a different solution.