Skip to content

Commit

Permalink
Improve channel docs and example code (#5898)
Browse files Browse the repository at this point in the history
* fix Step 2, template filename

* fix comment/example heex template filename to hold the script tag
  • Loading branch information
alexcybernetic authored Aug 14, 2024
1 parent 57846cb commit 412a07d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion guides/real_time/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Now our `conn.assigns` contains the `current_user` and `user_token`.

### Step 2 - Pass the Token to the JavaScript

Next, we need to pass this token to JavaScript. We can do so inside a script tag in `lib/hello_web/components/layouts/app.html.heex` right above the app.js script, as follows:
Next, we need to pass this token to JavaScript. We can do so inside a script tag in `lib/hello_web/components/layouts/root.html.heex` right above the app.js script, as follows:

```heex
<script>window.userToken = "<%= assigns[:user_token] %>";</script>
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/phx.gen.socket/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let socket = new Socket("/socket", {params: {token: window.userToken}})
// end
//
// Now you need to pass this token to JavaScript. You can do so
// inside a script tag in "<%= web_prefix %>/templates/layout/app.html.heex":
// inside a script tag in "<%= web_prefix %>/templates/layout/root.html.heex":
//
// <script>window.userToken = "<%%= assigns[:user_token] %>";</script>
//
Expand Down

0 comments on commit 412a07d

Please sign in to comment.