Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9077581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:24:08+00:00 2026-06-16T19:24:08+00:00

The code I’m using the version 4fcdbf2560 with the new router. In my application,

  • 0

The code

I’m using the version 4fcdbf2560 with the new router.

In my application, a user can be authenticated or not. The rendered template will not be the same depending on the authentication state.

I’ve manage this by redefining the function renderTemplate in the ApplicationRoute:

App.ApplicationRoute = Ember.Route.extend({
    renderTemplate: function() {
        this.render(App.authenticated() ? 'authenticated' : 'unauthenticated');
    }
});

My router is quite simple:

App.Router.map(function(match) {
    match('/').to('index');

    match('/sign').to('sign', function(match) {
        match('/in').to('signIn');
    });

    match('/dashboard').to('dashboard');
});

The IndexRoute is just here to redirect the user depending on the authentication state:

App.IndexRoute = Ember.Route.extend({
    redirect: function() {
        this.transitionTo(App.authenticated() ? 'dashboard' : 'signIn');
    }
});

The workflow

  1. A user navigates to /
  2. The ApplicationRoute is entered, as the user is not authenticated, the unauthenticated template is rendered
  3. The IndexRoute is entered, as the user is not authenticated, a redirection is made to signIn
  4. The signIn template is rendered into its parent template -> the unauthenticated template
  5. The user sign in successfully, route.transitionTo('dashboard') is called
  6. The dashboard template is rendered into its parent template -> the unauthenticated template

The questions

  • What’s wrong with my implementation ?
  • Why does the renderTemplate function is not called when the dashboard template is rendered ?
  • How can I force the application to re-render its template ?

Edit 2013-01-07

I’ve modified my code according to Evan’s answer.

My application template now looks like this:

{{#if isAuthenticated}}
    <h1>Authenticated</h1>
    {{outlet}}
{{else}}
    <h1>Unauthenticated</h1>
    {{outlet}}
{{/if}}

When the user lands on the application page, as he’s not authenticated, it’s the unauthenticated block which is rendered. Everything is working well except that nothing render into the {{outlet}} tag…

But when my application template looks like this (=without conditional tags):

<h1>Unauthenticated</h1>
{{outlet}}

…it works ! So I wonder if the {{outlet}} tag can be inserted between conditional tags.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:24:09+00:00Added an answer on June 16, 2026 at 7:24 pm

    I think it might be a mistake to have this logic in the Router; Instead this should be part of the ApplicationController.

    Since ember will automatically update the templates as application state changes you can create an ApplicationController that tracks the authentication state

    App.ApplicationController = Ember.Controller.extend({
        isAuthenticated: null
    });
    

    And construct your templates like this:

    <script type="text/x-handlebars" data-template-name="application">
        {{ #if isAuthenticated }}
            You are now logged in
        {{ else }}
            Please Log In
        {{ /if }}
    </script>
    

    Now you don’t actually have to worry about manually updating / rendering the template. As the internal (JS) state changes your template will automatically update to reflect the application state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code to create new form instance of a closed form using form name I
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Code: <?php //initializing script, do not modify session_start(); define('IN_SCRIPT', true); //so that global.php cannot
Code: <%=#{time_ago_in_words(comment.created_at)} ago %> What i'd like is for it not to have ABOUT
Code: LinkButton linkButton = new LinkButton(); linkButton.OnClientClick=changecolor;--i need to change this to on mouse
Code for default sms/mms app is available open. Can I modify this app (I
CODE height = objExcel1.Application.WorksheetFunction.CountA(ob3.Columns(1)) 'MsgBox(height) ReDim dataArray(height - 2, 0) ' -1 for 0
Code Random Randomizer = new Random () ; cardoneA = suits[Randomizer.nextInt(suits.length)]; cardoneAv = ranks[Randomizer.nextInt(ranks.length)];
code: Random Picker = new Random(); List<String> list = new ArrayList<String>(); list.add(card1); list.add(card2); list.add(card3);
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.