handlebars-pure-patterns

Handlebars Templating Standards

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "handlebars-pure-patterns" with this command: npx skills add ecelayes/roots-skills/ecelayes-roots-skills-handlebars-pure-patterns

Handlebars Templating Standards

The "Logic-less" Philosophy

  • Data Preparation: Templates should strictly DISPLAY data. All filtering, sorting, or complex math MUST happen in the application code (Controller/Service) before the data reaches the template.

  • Avoid Spaghettis: If you need more than two nested {{#if}} or {{#each}} blocks, consider refactoring the data structure or creating a custom helper.

Syntax & Helpers

  • Escaping:

  • Default {{ value }} is safe and escapes HTML characters.

  • Use {{{ value }}} (triple-stash) ONLY for trusted HTML strings (e.g., pre-sanitized content).

  • Custom Helpers:

  • Do not write complex inline logic. Instead of {{#if (eq (mod index 2) 0)}} , create a helper {{#if (isEven index)}} or, better yet, pre-calculate isEven in the data model.

  • Register helpers for formatting dates, currencies, and translation.

Component Architecture (Partials)

  • Atomic Design: Break complex UIs into small files in the partials/ directory.

  • Naming convention: _card.hbs , _navbar.hbs .

  • Context Passing:

  • Explicit Context: {{> myPartial specificData }} is preferred over implicit context inheritance.

  • Block Partials: Use {{#> layout}} ... {{/layout}} for wrapping content (like slots).

Troubleshooting

  • Missing Properties: Handlebars fails silently on undefined properties. Ensure your data object structure strictly matches the template expectations.

  • Prototypes: If using Mongoose/ORMs, convert documents to Plain Old JavaScript Objects (POJOs) (e.g., .lean() or .toJSON() ) before passing to Handlebars to avoid prototype access issues.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

htmx-universal-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

koa-advanced-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

Csv Analyzer Cn

CSV数据分析工具。数据统计摘要、SVG图表生成、条件筛选、文件合并、数据清洗、格式转换(JSON/HTML/Markdown/SQL)、HTML分析报告。CSV analyzer with stats, SVG charts, filtering, merging, cleaning, format conve...

Registry SourceRecently Updated
General

Tripit Calendar

Read upcoming TripIt travel plans from a TripIt iCal feed; use for next trip, upcoming travel, itinerary, flight or hotel bookings already in TripIt; do not...

Registry SourceRecently Updated