FHEM Forum

FHEM => English Corner => Thema gestartet von: malc_b am 20 Januar 2017, 10:37:04

Titel: tabletUI template just text
Beitrag von: malc_b am 20 Januar 2017, 10:37:04
Does anyone know a way to use tablet-ui template function to pass plain text in?  I have some repeated code that I want to template.  In that are 2 places where I have a header with a title.  I want to pass in the title as a parameter.  Looking at the code for template I reckon that is it just replacing all matching variable so it works ok with data-device="param1" where it replaces the param1 with the passed it name.  I've tried a simple label:

<div data-type="label" data-pre-text="pNAME" class="big inline"></div>

but that doesn't work.  I could make the title (pNAME) an attribute of the device and get label to fetch that but that seems a long winded way just to pass in a fixed text label.  Is there any other way?
Titel: Antw:tabletUI template just text
Beitrag von: redlav am 23 Januar 2017, 16:44:08
Hi,

I have the text of a header in the state of a dummy:


<header>
    <div data-type="label"
            data-device="dummy1"
            data-get="STATE"
            class="">
    </div>
</header>


Is this what you mean?
Titel: Antw:tabletUI template just text
Beitrag von: malc_b am 23 Januar 2017, 17:31:04
No.  What I'm doing at the moment is adding a user attribute to my max thermostat in fhem.  I'm then fetching that user attribute with a label div.  This is more or less what you are doing.  But this is a long winded way of doing it.  I just want to pass in say the parameter "LOUNGE" and have the template use "LOUNGE".  At the moment I'm passing it "A" and it is using "A" to get "B", a fixed text string, so it can display "B", hence it would be simpler just to pass it "B". 
Titel: Antw:tabletUI template just text
Beitrag von: redlav am 23 Januar 2017, 19:16:09
Da kann ich dir leider nicht weiterhelfen :-\
Titel: Antw:tabletUI template just text
Beitrag von: malc_b am 31 Januar 2017, 10:00:58
I've found a solution and it is simple.  The parameter replace is just a regular expression replace so it is NOT just for widget parameters but any text.  I was trying to create a label widget but this works:

<header>pLabel</header>


where pLabel is the name of the parameter you are passing in.  NOTE, as it just replaces text do NOT make the parameter name something you also have in the text e.g. a parameter "heating" and in the text "central heating".