# Hoe gebruik je het user-veld in een hbr-bestand?

**URL:** https://meta.discourse.org/t/how-to-use-user-field-in-hbr-file/218066
**Category:** Development
**Created:** [13 februari 2022 om 23:05 UTC](https://meta.discourse.org/t/how-to-use-user-field-in-hbr-file/218066 "2022-02-13T23:05:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![th21](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/th21/32/211915_2.png) [@th21](https://meta.discourse.org/u/th21)
#### Post date: [13 februari 2022 om 23:05 UTC](https://meta.discourse.org/t/how-to-use-user-field-in-hbr-file/218066/1 "2022-02-13T23:05:00Z")

</div>

I was trying to let users choose whether show likes on desktop/mobile pages based on

> [@Display replies and likes count in mobile view](https://meta.discourse.org/t/display-replies-and-likes-count-in-mobile-view/203473):
>
> A component to display replies and likes count in mobile view Display likes count in addition to replies count on mobile view Support [Topic List Excerpts Theme Component](https://meta.discourse.org/t/topic-list-excerpts-theme-component/151520) Update: Now support customized icon eyeglassesPreview PREVIEW\_LINKhammer_and_wrenchRepository [https://github.com/notedboi/discourse-mobile-extend-display](https://github.com/notedboi/discourse-mobile-extend-display)questionInstall Guide [How to install a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682)open_bookNew to Discourse Themes? [Beginner’s guide t…](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966)

and would like to know how to use user custom filed in a .hbr like this.

> <https://github.com/notedboi/discourse-mobile-extend-display/blob/main/mobile/head_tag.html>

or is it possible to apply conditional css based on the user field?

---

<div class="post-metadata">

### Author: ![th21](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/th21/32/211915_2.png) [@th21](https://meta.discourse.org/u/th21)
#### Post date: [21 februari 2022 om 01:49 UTC](https://meta.discourse.org/t/how-to-use-user-field-in-hbr-file/218066/2 "2022-02-21T01:49:06Z")

</div>

After some investigation, I think it’s impossible because the hbr file only knows values that pass into the template and we can’t pass a computed value into it?

---

<div class="post-metadata">

### Author: ![th21](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/th21/32/211915_2.png) [@th21](https://meta.discourse.org/u/th21)
#### Post date: [13 juli 2022 om 05:52 UTC](https://meta.discourse.org/t/how-to-use-user-field-in-hbr-file/218066/3 "2022-07-13T05:52:31Z")

</div>

```plaintext
<script type="text/discourse-plugin"
        version="0.8">
  const testComponent = require('discourse/app/raw-views/list/posts-count-column').default;
  testComponent.reopen({
    user: function() {
        return Discourse.User.current()
    }.property()
  });
</script>

```

I tried to use `repoen()` on the `posts-count-column` component to pass currentUser value as the example below but got an error, I think maybe only a limited type of component support this method?

> [@Override template only on specific page](https://meta.discourse.org/t/override-template-only-on-specific-page/132288/2):
>
> ```plaintext
> <script type="text/discourse-plugin"
> version="0.8">
> const categoriesOnlyComponent = require('discourse/components/categories-only').default;
> categoriesOnlyComponent.reopen({
> isHomepage: function() {
> return !this.parentView.searchService.contextType
> }.property()
> });
> </script>
> 
> ```

And I find another way to pass the currentUser value into a nested hbr, by overwrite from top to bottom, add {{raw “list/posts-count-column” topic=topic tagName=“div” **user=user** }} to insert the value

```plaintext
<script type='text/x-handlebars' data-template-name='mobile/list/topic-list-item.raw’>
<script type='text/x-handlebars' data-template-name='list/post-count-or-badges.hbr'
<script type="text/x-handlebars" data-template-name="list/posts-count-column.hbr">

```

Does emberjs have a provide/inject function like vue for passing value into a nested template? I did some search but didn’t find much info. Any suggestion on this?
