Re: [tw] Re: [TW5] Default values for templates

2015-09-20 Thread Evolena
Le dimanche 20 septembre 2015 00:29:51 UTC+2, Tobias Beer a écrit :
>
> Now I'm confused, because... what was I testing earlier? ^_^
>
> [...] one of the last times this kicked in:
>
> #1939 saving a tiddler with non-empty input fields 
> 
>

Haha, when testing I thought it didn't work because of that! 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1b7e238e-8301-4658-be53-9d97e854abb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-20 Thread FrD
Hi Evolena,

Great news !
I didn't know of default values for macros. I've learnt a lot today.
Most of my use-cases are text references like {{!!title}} or some other 
field as it is common when using templates.

Thanks !

FrD


Le samedi 19 septembre 2015 21:44:08 UTC+2, Evolena a écrit :
>
> As all the examples you provided used a literal default value, it could 
> have been a suitable solution.
>
> But... after a little test... good news: a macro or variable seems to be 
> OK as default parameter value of a macro:
>
> \define default() test
> \define somevariablevalue(value:<>) $value$
>
> <$macrocall $name="somevariablevalue" value=<>/>
>
> And textreference are ok too:
>
> \define somevariablevalue(value:{{!!field}}) $value$
>
> <$macrocall $name="somevariablevalue" value=<>/>
>
> What else? ^^
> (I've learnt some things today too!)
>
> Le samedi 19 septembre 2015 21:35:20 UTC+2, FrD a écrit :
>>
>> Hi Evolena,
>>
>> Thanks for the tip. I've tested it : it works.
>> But as Tobias says, it's only useful for literals.
>>
>> Anyway it's pretty useful for many cases.
>>
>> Thanks
>>
>> FrD
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f8560461-c7f1-4e2c-90ff-f12e162e9e77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-20 Thread Tobias Beer

>
> Haha, when testing I thought it didn't work because of that!
>

:D

do the double-check is the mother of correctitude

- tb 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/0e9912dd-447c-4752-80e9-d8f9ba220547%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread Evolena
As all the examples you provided used a literal default value, it could 
have been a suitable solution.

Le samedi 19 septembre 2015 21:35:20 UTC+2, FrD a écrit :
>
> Hi Evolena,
>
> Thanks for the tip. I've tested it : it works.
> But as Tobias says, it's only useful for literals.
>
> Anyway it's pretty useful for many cases.
>
> Thanks
>
> FrD
>
> Le samedi 19 septembre 2015 17:56:31 UTC+2, Evolena a écrit :
>>
>> I've not tested what I propose, but you cloud try to define macros in 
>> your template to set the default values.
>>
>> For example, if your variable in the template is somevariable:
>>
>> \define somevariablevalue(value:"default") $value$
>>
>> <$macrocall $name="somevariablevalue" value=<>/>
>>
>>
>> OK, it is less readable than only <>, but it may works (not 
>> tested, again).
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/afeb7b68-119a-4164-b881-58b290d5879e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread FrD
Hi Evolena,

Thanks for the tip. I've tested it : it works.
But as Tobias says, it's only useful for literals.

Anyway it's pretty useful for many cases.

Thanks

FrD

Le samedi 19 septembre 2015 17:56:31 UTC+2, Evolena a écrit :
>
> I've not tested what I propose, but you cloud try to define macros in your 
> template to set the default values.
>
> For example, if your variable in the template is somevariable:
>
> \define somevariablevalue(value:"default") $value$
>
> <$macrocall $name="somevariablevalue" value=<>/>
>
>
> OK, it is less readable than only <>, but it may works (not 
> tested, again).
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/34a8c1fa-5330-483c-be9b-88eead0a9e1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread Tobias Beer
Hi Evolena,
 

> But... after a little test... good news: a macro or variable seems to be 
> OK as default parameter value of a macro:
>

Now I'm confused, because... what was I testing earlier? ^_^

Must have been Joe Pesci 
, or... one of the 
last times this kicked in:

#1939 saving a tiddler with non-empty input fields 


Quite happy to see it work, after all.

- tb

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b1d29d79-6486-4c81-a41d-953b5a3f2b37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread Tobias Beer
Hi Evolena,
 

> \define somevariablevalue(value:"default") $value$
>
> <$macrocall $name="somevariablevalue" value=<>/>
>

Nice idea. The biggest constraint would be, that the "default" value has to 
be a literal and cannot be an evaluated textreference or macro / variable.

- tb

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/7a93bab9-a8f3-4259-a830-8bc4232e719d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread 'Andreas Hahn' via TiddlyWiki

Am 19.09.2015 um 15:07 schrieb Tobias Beer:

The way do it seems about right.


It does look right, however, an empty string for the filter parameter is 
regarded as no filter parameter, therefore you have to design a filter, 
that is empty when the variable is empty (which is hard) , but is not an 
empty string itself.


/Andreas

--
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/55FD6394.7030803%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread FrD
Hi again

Sorry I can't modify my previous post.

In the example, you have to replace "sometext1" by "somevariable1" !

FrD


Le samedi 19 septembre 2015 15:46:54 UTC+2, FrD a écrit :
>
> Hi,
>
> @Tobias :
>
> Well my "real life" template is a it complicated but it's easy to make an 
> experiment.
> Suppose the template you want to use is : <><> 
> {{!!title}}
> In a test  template you can try 3 ways of writing the template :
>
> \define myFilter() foobar$(somevariable)$ +[removesuffix[foobar]]
>
> First expression :
> <><> {{!!title}}
>
> Second expression :
> <$set name="somevariable1" filter=<> value=<> 
> emptyValue="Default value">
> <><> {{!!title}}
> 
>
> Third expression :
> <$set name="somevariable1" filter=<> value="Default value" 
> emptyValue=<>>
> <><> {{!!title}}
> 
>
> @Andreas :
>
> You're right : the filter design is the point. I came to the same 
> conclusion and that's why I've been using this strange filter.
>
> But it's twisted and I was wondering if there was a simpler way to specify 
> a default value.
>
> Thanks to both of you !
>
> FrD
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/7d8ce578-aea3-46d6-98ee-0d19ed0d3ef3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread Tobias Beer
Hi Frd,
 

> But it's twisted and I was wondering if there was a simpler way to specify 
> a default value.
>

A "default" how? When your filter returns empty, then you have *emptyValue* 
to cater for a default.
Otherwise at what point do you want your default to kick in if not for when 
your computed value is blank?

So, I don't see why your third expression would declare a value parameter,
because I don't see when that would ever kick in.

Best wishes,

— tb

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ab4fd0a8-f65c-49a8-86b0-dc68efdb0932%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread FrD
Hi,

@Tobias :

Well my "real life" template is a it complicated but it's easy to make an 
experiment.
Suppose the template you want to use is : <><> 
{{!!title}}
In a test  template you can try 3 ways of writing the template :

\define myFilter() foobar$(somevariable)$ +[removesuffix[foobar]]

First expression :
<><> {{!!title}}

Second expression :
<$set name="somevariable1" filter=<> value=<> 
emptyValue="Default value">
<><> {{!!title}}


Third expression :
<$set name="somevariable1" filter=<> value="Default value" 
emptyValue=<>>
<><> {{!!title}}


@Andreas :

You're right : the filter design is the point. I came to the same 
conclusion and that's why I've been using this strange filter.

But it's twisted and I was wondering if there was a simpler way to specify 
a default value.

Thanks to both of you !

FrD

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/d96e523d-f555-4bc6-ad51-4e58ca2196e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread FrD
Hi Tobias,

I can see it's not easy to explain my use case.

In some occasions I find it easier to pass some parameters to a template. 
It allows me to write more generic templates and re-use them in different 
contexts

So inside the template I put some placeholders for variables to be defined, 
like $(somevariable)$.
When the variables are defined when the template is called, it works fine. 
But I'd like to be able to call the template without defining all the 
variables : to have default values.

The default value of a variable is supposed to be used by the template when 
the variable is not defined when the template is called.

So inside the template I have to check whether the variable is defined or 
not :
If the variable is defined, that's fine, let's use its value.
If not, the default value is affected to the variable.

The set widget allows to affect a value to a variable according to the 
result of a filter (empty list of tiddlers or not). So I tried to go this 
way.
But my problem was to design the filter. I ended with a fancy filter.
I was wondering if there is a better way to do that :
- using something else than the set widget with the filter and emptyValue,
- or using a more straightforward filter.

I hope it's a bit clearer now ?

FrD

Le samedi 19 septembre 2015 16:54:28 UTC+2, Tobias Beer a écrit :
>
> Hi Frd,
>  
>
>> But it's twisted and I was wondering if there was a simpler way to 
>> specify a default value.
>>
>
> A "default" how? When your filter returns empty, then you have 
> *emptyValue* to cater for a default.
> Otherwise at what point do you want your default to kick in if not for 
> when your computed value is blank?
>
> So, I don't see why your third expression would declare a value parameter,
> because I don't see when that would ever kick in.
>
> Best wishes,
>
> — tb
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/fb8b83c7-93dd-42f0-a4cd-2b6dae2fc91b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [tw] Re: [TW5] Default values for templates

2015-09-19 Thread Evolena
I've not tested what I propose, but you cloud try to define macros in your 
template to set the default values.

For example, if your variable in the template is somevariable:

\define somevariablevalue(value:"default") $value$

<$macrocall $name="somevariablevalue" value=<>/>


OK, it is less readable than only <>, but it may works (not 
tested, again).

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8b69b1bf-9813-4d8f-ab0f-672d27da80a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.