Skip to content

Add an example on how to access controller in gjs/gts templates #2183

Open

Description

@urbany

It would be helpful to have here an example here: https://guides.emberjs.com/v6.9.0/routing/controllers/

HEre is the current exmaple with gjs valid code, could be added to the page or replaced

<template>
  <h1>{{@model.title}}</h1>
  <h2>by {{@model.author}}</h2>

  <div class='intro'>
    {{@model.intro}}
  </div>
  <hr>

  {{#if @controller.isExpanded}}
    <button type="button" {{on "click" @controller.toggleBody}}>Hide Body</button>
    <div class="body">
      {{@model.body}}
    </div>
  {{else}}
    <button type="button" {{on "click" @controller.toggleBody}}>Show Body</button>
  {{/if}}
</template>

Thanks in advance

Activity

  1. mansona commented on Jan 14, 2026

    @mansona
    Member

    Hey thanks for the issue report! how do you feel about contributing a PR to fix this?

    I transferred this issue to the repo that would need the contribution, the file in question is this: https://github.com/ember-learn/guides-source/blob/master/guides/release/routing/controllers.md and you should even be able to use the GitHub UI to do the work if you would prefer 👍

  2. mansona commented on Jan 14, 2026

    @mansona
    Member

    And for the record you're 100% right, this should have been updated when we moved things to GJS 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions