How to add helper for connector?


(SMHassanAlavi) #1

How can I add add helpers for a connector in templates folder for an outlet?


(Mittineague) #2

This is a year old and I haven’t revisited it since so be warned YMMV.

In plugin.rb I registered the helper file.
register_asset "javascripts/helpers/post-image-links.js.es6"
* may not be necessary, as “es6” files are auto-magically included.

The es6 helper file had the script stuff

Ember.Handlebars.helper('post-image-links', function(param) {
  var output = " ";
⋮
	return output;
});

and the connector hbs

{{#if Discourse.SiteSettings.post_image_links_active}}
  <div class="post-image-links">
    {{#if cooked}}
      {{#if (post-image-links) }}
        {{{ post-image-links cooked }}}
      {{/if}}
    {{/if}}
  </div>
{{/if}}

which went into a hacked post.hbs file

⋮
        <div class='cooked'>
          {{{cooked}}}
	  {{plugin-outlet "in-cooked"}}
          {{#if firstPost}}
            {{plugin-outlet "topic-after-cooked"}}
          {{/if}}
        </div>
⋮