Skip to content

Commit

Permalink
Allow template override using signedInTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
queso committed Jun 5, 2014
1 parent 34ddd13 commit eaca425
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
16 changes: 15 additions & 1 deletion client/views/accountButtons/accountButtons.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Template.entryAccountButtons.helpers
entryAccountButtonsHelpers = {
profileUrl: ->
return false unless AccountsEntry.settings.profileRoute
AccountsEntry.settings.profileRoute


wrapLinksLi: ->
if AccountsEntry.settings.wrapLinks
Template.wrapLinks
Expand All @@ -26,3 +27,16 @@ Template.entryAccountButtons.helpers

entrySignUp: ->
AccountsEntry.settings.entrySignUp
}

Template.entryAccountButtons.helpers entryAccountButtonsHelpers

Template.entryAccountButtons.helpers
signedInTemplate: ->
if AccountsEntry.settings.signedInTemplate
Template[AccountsEntry.settings.signedInTemplate].helpers(entryAccountButtonsHelpers)
Template[AccountsEntry.settings.signedInTemplate]
else
Template.entrySignedIn

Template.entrySignedIn.helpers entryAccountButtonsHelpers
15 changes: 1 addition & 14 deletions client/views/accountButtons/accountButtons.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
<template name="entryAccountButtons">
{{#if currentUser}}

{{#if profileUrl}}
{{#wrapLinksLi}}
<a class='profileLink' href='{{profileUrl}}'>{{{beforeSignedInAs}}}{{signedInAs}}</a>
{{/wrapLinksLi}}
{{else}}
{{#wrapLinksLi}}
<p class="navbar-text">{{{beforeSignedInAs}}}{{signedInAs}}</p>
{{/wrapLinksLi}}
{{/if}}

{{#wrapLinksLi}}
<a href="/sign-out">{{{beforeSignOut}}}{{t9n "signOut"}}</a>
{{/wrapLinksLi}}
{{> signedInTemplate}}
{{else}}

{{#wrapLinksLi}}
Expand Down
15 changes: 15 additions & 0 deletions client/views/accountButtons/signedIn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template name="entrySignedIn">
{{#if profileUrl}}
{{#wrapLinksLi}}
<a class='profileLink' href='{{profileUrl}}'>{{{beforeSignedInAs}}}{{signedInAs}}</a>
{{/wrapLinksLi}}
{{else}}
{{#wrapLinksLi}}
<p class="navbar-text">{{{beforeSignedInAs}}}{{signedInAs}}</p>
{{/wrapLinksLi}}
{{/if}}

{{#wrapLinksLi}}
<a href="/sign-out">{{{beforeSignOut}}}{{t9n "signOut"}}</a>
{{/wrapLinksLi}}
</template>
3 changes: 2 additions & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ Package.on_use(function(api) {
'client/views/error/error.html',
'client/views/error/error.coffee',
'client/views/accountButtons/accountButtons.html',
'client/views/accountButtons/accountButtons.coffee',
'client/views/accountButtons/_wrapLinks.html',
'client/views/accountButtons/signedIn.html',
'client/views/accountButtons/accountButtons.coffee',
'client/t9n/english.coffee',
'client/t9n/french.coffee',
'client/t9n/german.coffee',
Expand Down

1 comment on commit eaca425

@timbrandin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I can't get this to work in the latest version..

Please sign in to comment.