Skip to content

Instantly share code, notes, and snippets.

@vybs
Created December 9, 2011 00:30
Show Gist options
  • Save vybs/1449461 to your computer and use it in GitHub Desktop.
Save vybs/1449461 to your computer and use it in GitHub Desktop.
simple skills list dust template
{#profile_skill}
<div class="section" id="profile-skills" style="display:block">
<div class="header">
<h2>{@pre:i18n text="Skills"}</h2>
</div>
{?skills} {! we still want to display the Skills heading, even if the number of skills is zero !}
<div class="content">
<ol class="skills" id="skills-list">
{#skills}
<li class="competency show-bean">
<span class="miniprofile-container jellybean">{.name}</span>
</li>
{/skills}
</ol>
</div>
{/skills}
</div>
{/profile_skill}
"profile_skill": {
"skills": [{
"name": "JavaScript"
}, {
"name": "Ruby"
}, {
"name": "Java"
}],
"i18n_skills": "Skills" // when rendered with current locale en_US
}
@moxley
Copy link

moxley commented Dec 14, 2011

Interesting to see the unnecessary "hasSkills" property. Could this be a leftover from an earlier mustache implementation? Or could it be an artifact from the Java layer?

@vybs
Copy link
Author

vybs commented Dec 15, 2011

Interesting you ask! Yes, we tried mustache before moving to dust,js!

@vybs
Copy link
Author

vybs commented Dec 15, 2011

One more interesting case !

Say we want to do something like this

{?summary || ?specialties}
{?summary}

{summary}

{/summary}
{?specialties}

{specialties}

{/specialties}

And dust does not allow you to do expressions, since it is wants to be logic-less.

Even more ugly is like sending hasSummaryorSpecialities boolean is JSON

we thought hard on eliminating these superflous fields in the JSON

We wrote a @if helper! More details in the subsequent blog post

@idris
Copy link

idris commented Jan 5, 2012

Slightly unrelated, but how do you render the "chrome" of these pages? Is that still done on the backend with something like Sitemesh?

@vybs
Copy link
Author

vybs commented Jan 5, 2012

We are moving away from full page model.

We used to use site-mesh, but we do not, since we have to buffer the response and we lose the progressive rendering

We have been building a smart evented/async proxy infront of all the apps to act as a aggregator for content from diff apps.

@seriousManual
Copy link

Hi,
I'm currently playing around with your extended version of dustjs and I'm curious about the way you approached internationalisation.
I see that "{@pre:i18n text="Skills"}" tag and I wonder how that is implemented.
Until now I have not seen that i18n feature in dustjs itselfs, is it a extension you did?
And what about that @pre tag?
Is it a helper you implemented?

Thanks in advance!

@idris
Copy link

idris commented May 15, 2012

Yeah, I'd be very interested in a blog post or open-sourcing of your i18n infrastructure. (Or at least just a brief comment here on what it looks like) :)

@vybs
Copy link
Author

vybs commented May 15, 2012

We explored a lot of options and decided to process the template on the server.

A number of our new pages/features are using this and soon will be ramped to production

blog post will be out soon. ( in a week) stay tuned.

We are working on open sourcing the same ( mid June )

@fitzchak
Copy link

Looking for the blog post too... :)

@praveenvedanth
Copy link

Can we completely stop using server side scripting in jsp etc ?. How do we embed dynamic json data into html without using jsp at all. I am not talking about getting json data from ajax. Its when we have send following in the response, html ( static ) + script tags including templates ( static ) + json data ( dynamic ) .

@sivikt
Copy link

sivikt commented May 27, 2013

Thank you for the great articles at linkedin.
I have a kind of general question. As I understood you moved completely to JS templating - only html and js. Right? It's exciting! Especially for us who used to use JSP/GSP/PythonWebFrameworks and so on. But how do you path to templates such params as context path, js libs versions, html headers and meta info? I guess in such cases you use server side template processing? Sorry if I repeat previous questions..

@alohaTu
Copy link

alohaTu commented Nov 1, 2013

Hi Veena,
I have some cases that want to compile dust template on server, too. I decide use Nodejs as js engine on server.
On the above your comment you mentioned that you will have blog post about processing template on server
Would you mind give me a link of that post, I've had a searching and still dont see any articles that relate compiling dust template on server.
And you had mentioned about your open source, so how is about it?? Do you mind give me some ideas about compiling template on Node js

@vybs
Copy link
Author

vybs commented Dec 8, 2013

@alohaTu, Never made it publish the post, now I look back, compiling dust on the server is easy ( using node.js or Rhino or even V8 engine if you use a c++ stack). it is basically 4 lines of code to compile template in node.js Are you still wondering how.?

check out the paypal's open sources node module for dust rendering
https://github.com/paypal/adaro

@vybs
Copy link
Author

vybs commented Dec 8, 2013

@sivikt oops for been so late! But the answer is simple, any data to the dust template has to be in JSON including what you ask for .....params as context path, js libs versions, html headers and meta info. But why would you need html headers to display on the dust template? ....

@alohaTu
Copy link

alohaTu commented Dec 12, 2013

@vybs : ok thank you, I will check this link, I think I will use node to compile Dust, and when you publish that post, please let me know that link, I alway keep follow any articles that relate about Dust :D

@ccit-spence
Copy link

@vybs How has the progress been for UI composition with DustJS? Still evaluating things on our end. The main thing I am trying to solve is UI composition in a microservices environment. Currently everything is based on Java/Spring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment