longshotlabs / meteor-template-extension

A Meteor package: Replace already defined templates, inherit helpers and events from other templates
https://atmospherejs.com/aldeed/template-extension
MIT License
220 stars 20 forks source link

replaces(templateName) not working #46

Closed runlevelsix closed 7 years ago

runlevelsix commented 8 years ago

I'm using Meteor 1.2.1 with template-extension v4.0.0 in a large-ish project and I can't seem to get the replaces(templateName) to work.

I need to rearrange HTML in a template created by autoform so I can take advantage of an stylesheet that makes nicer-looking radio buttons (awesome-bootstrap-checkbox). So, I copied the afRadioGroup into a new, renamed template (MyafRadioGroup), in which I rearranged the HTML tags. I call Template.MyafRadioGroup.replaces('afRadioGroup') in JS, but when I inspect my rendered code, the new template has not replaced the old one.

I'm not sure what I'm doing wrong. I've pasted my code below.

<!-- client/components/MyafRadioGroup.html -->
<template name="MyafRadioGroup">
  <div class="af-radio-group" {{dsk}}>
  {{#each this.items}}
    <div class="radio">
      <input type="radio" value="{{this.value}}" {{atts}}>
      <label>
        {{this.label}}
      </label>
    </div>
  {{/each}}
  </div>
</template>
// client/components/MyafRadioGroup.js
Template.MyafRadioGroup.replaces("afRadioGroup");
elGusto commented 8 years ago

Probably you need to replace the template that is actually rendered. Autoform has "templates" (bootstrap, ionic, etc) so you need to replace the afRadioGroup_bootstrap template if you are using bootstrap.

gregory commented 8 years ago

+1 for @elGusto - @runlevelsix you can use the meteor template inspector through the chrome extension to figure out what is the exact template that is being used.