Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:11:14+00:00 2026-06-10T20:11:14+00:00

I’m using dust templates and one aspect of the design has been bugging me.

  • 0

I’m using dust templates and one aspect of the design has been bugging me. This makes me wonder if I’m “doing it wrong” so I thought I would ask S.O. Is there a way to create multiple-level inheritance in dust.js with blocks and inline partials? Lets say you have a base template with layout, an inheriting template that overrides some content, and then yet another template inheriting from that template that wishes to selectively override some content. Normally I would imagine it works by the last inheriting template providing the final overriding values. The inline partial syntax, however, seems to only work on a single level. Here’s a contrived example that should show what I’m talking about.

template 1 test_base.dust:

<h1>
{+document_title/}
</h1>
{+content}
<p>Some great content.</p>
{/content}

template 2 test_level1.dust:

{>test_base/}
{<document_title}Level 1{/document_title}
{<content}
<p>Other great content</p>
{/content}

template 3 test_level2.dust:

{>test_level1/}
{<document_title}Level 2{/document_title}

Rendering these templates I get the following results:

dust.render('test_base', {}, function(err, data) { console.log(data); } );
"<h1></h1><p>Some great content.</p>"

dust.render('test_level1', {}, function(err, data) { console.log(data); } );
"<h1>Level 1</h1><p>Other great content</p>"

dust.render('test_level2', {}, function(err, data) { console.log(data); } );
"<h1>Level 1</h1><p>Other great content</p>"

I’ve read over the docs a few times but it seems like you can inherit templates from multiple levels but you can only override a single template defined block. So am I “doing it wrong”? Is there a way to accomplish multiple level inheritance with selective overrides using blocks and inline partials? Is there another way to do this and keep the templates DRY?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:11:16+00:00Added an answer on June 10, 2026 at 8:11 pm

    Unfortunately it looks like this inheritance model isn’t supported. Found this discussion on the linkedin fork: https://github.com/linkedin/dustjs/issues/101

    That discussion referenced a particular passage in the docs:

    … Inline partials never output content
    themselves, and are always global to the template in which they are defined,
    so the order of their definition has no significance. They are passed to all templates invoked by
    the template in which they are defined.

    So I have two interpretations of this: one the order is non-deterministic and possibly based on how the templates are compiled. The second potential interpretation is that the global definition always supersedes for the template in which it’s defined and any templates that template calls. If that’s the correct interpretation then inline partials in parent templates will always ‘win’ if the block they’re overriding is at that same level or higher in the inheritance hierarchy. That’s the opposite of what I would expect and makes using inline partials for multi-level inheritance impossible (at least with the same named block).

    Seems like this is a dead end, any other ideas on how this behavior could be accomplished in Dust?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.