chatra:react-template-helper

v1.1.0Published 2 weeks ago

chatra:react-template-helper

Enhanced React Template Helper for Meteor Blaze with block component support.

Based on meteor/react-packages react-template-helper with added support for block components that can render Blaze content as React children.

Installation

meteor add chatra:react-template-helper

Usage

Inclusion Syntax (Original Behavior)

{{> React component=MyButton label="Click me" onClick=handleClick}}

Block Syntax (Enhanced)

Renders Blaze content as React children:

{{#React component=MyAccordion title="Settings"}}
    <p>This Blaze content becomes React children!</p>
    {{> someOtherBlazeTemplate}}
{{/React}}

This is equivalent to:

1<MyAccordion title="Settings">
2    <p>This Blaze content becomes React children!</p>
3    <SomeOtherBlazeTemplate />
4</MyAccordion>

Block syntax works correctly inside {{#each}} loops — each iteration preserves its own Blaze scope (variables, data context, etc.).

How It Works

  1. When used as {{#React}}...{{/React}}, the package captures the Blaze contentBlock and parentView
  2. A BlazeContentBlock React component renders the content block via Blaze.render() with the original parent view
  3. This preserves the full Blaze scope chain ({{#each}} variables, {{#let}} bindings, data contexts)
  4. The Blaze view is cleaned up when the React component unmounts

Migration from react-template-helper

Replace in .meteor/packages:

- react-template-helper
+ chatra:react-template-helper

All existing {{> React ...}} usage will continue to work unchanged.

Dependencies

  • react 15.3 - 19
  • react-dom 15.3 - 19

Publishing

To publish a new version to Atmosphere:

cd react-template-helper
meteor publish

Make sure you're logged in with meteor login and have publish rights for the chatra organization.