Comment accéder aux données utilisateur dans un connecteur de sortie hbs ?

I am working on a plugin that has to render a notice to some specific users in the top area of the website where notices show up. The plugin outlet that I am trying to override is:
{{plugin-outlet name="top-notices" tagName="" args=(hash currentPath=router._router.currentPath)}}

I am able to get a static version of the connector to work. I created the following file at this path: plugins/discourse-user-throttle/assets/javascripts/discourse/templates/connectors/top-notices/throttle_info.hbs



This line is working file. But the username does not show
{{{user.username}}}

The issue I am facing is that the {{{user.username}}} doesn’t username. How can that be done?

I found out using console log that the user is accessible as currentUser:

{{{currentUser.displayName}}}

1 « J'aime »

Salut, y a-t-il des instructions sur la façon de voir les propriétés de currentUser ? Je n’arrive pas à comprendre comment ou où l’enregistrer/le visualiser. Je veux pouvoir accéder au nom de currentUser et l’afficher sur ma page.

Salut,

Si vous voulez dire comment enregistrer des données dans un modèle, vous pouvez utiliser {{log data_here}} et cela devrait s’afficher dans la console du navigateur.

Vous pouvez également utiliser l’API : api.getCurrentUser().
Par exemple, dans la section \u003chead\u003e de votre thème/composant en HTML :

<script type="text/discourse-plugin" version="0.8">
  console.log(api.getCurrentUser());
</script>
1 « J'aime »