Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Creating Reusable Components

$
0
0
Thanks Alex.

Is this the Bitovi recommended way?

And while my method seems weird, is it the unaccepted way?

I just thought it would be nice (and easy) to say "insert one of these content panel components and fill it with this content (another component).

Actually got my experiment to work last night.
  1. steal('can',
        'myapp/components/content_panel/views/content_panel.mustache',
        'myapp/helpers/mustache_helpers.js', function(can, contentPanelTmpl) {

        return function(scope) {

            can.view.registerView('contentTmpl', scope.contentTag);
            
            can.Component.extend({
                tag: 'content-panel',
                template: contentPanelTmpl,
                scope: scope
            });
        };
    })
  2. <div class="widget small coolInset">
        <div id="panelHeader" class="head">
            <h5 class="{{iconClass}}">{{l10n appTitle}}</h5>
        </div>
        <div class="body">
    <div id="panelContent" class="panel">
    {{>contentTmpl}}
    </div>
        </div>
    </div>
  3. ContentPanel({
        appTitle: 'appTitle',
        iconClass: 'iSettings',
        contentTag: "<shares-settings></shares-settings>"
    });

I don't know. It seems like a neat way to package reusable components.

Viewing all articles
Browse latest Browse all 3491

Trending Articles