chatra:react-template-helper

v1.0.0Published 3 days 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

The gadicc:blaze-react-component dependency is automatically included.

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>

How It Works

  1. When used as {{#React}}...{{/React}}, the package captures the Blaze contentBlock
  2. It registers the content block as a dynamic template with a unique name
  3. It uses gadicc:blaze-react-component to render the Blaze content as a React child
  4. The dynamic template is cleaned up when the component is destroyed

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
  • gadicc:blaze-react-component (included automatically)

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.