Access HTML data from helper

Lets say I have a simple helper:

someClass: function () {
  \\anway to get the value of the html data currently being rendered?
}

That is used like this:

<li class="{{someClass}}"><a href="">1</a></li>

Is it possible to access the value of the HTML data (specifically the value “1”) from within the helper block?

Thanks!

Template.instance().$(‘selector_for_that_a_tag’).innerHTML ?
I would expect something like that.

Thanks for your suggestion but it wont work because I wont necessarily know what element is being rendered. If there were a "this" that would return the html element, that would be ideal.

Where does your ‘1’ come from?

If its the data bound to the template just access that and don’t deal with the dom.

Otherwise what @shock said. Template helpers are bound to the whole template and not to the one tag they are used in so a this is out of the question. Which is why selecting it using Shock’s example is useful.

The selector can get smaller and smaller if you’re templates are compartmentalized enough too.

Perhaps elaborating on your overall goal at least at one level of the problem higher might help us to help you out?

1 Like

@href
This question was more of a “can I even do this” type of deal. I was just curious if accessing the HTML data from the helper was possible, I don’t have any working code to show.