Hello Tony!
Yes, I modified the code and now is shorter and modular!
- Mohammad
On Tuesday, August 21, 2018 at 6:53:56 PM UTC+4:30, TonyM wrote:
>
> Mohammad,
>
> a braindump before I go to bed.
>
> With a little work you could add a parameter for the alert-class "primary"
> "Secondary" and "danger" then build the "alert $alert-class$" string.
>
> Thus you could use additional ones by creating the matching class and
> calling the one macro with different class names. You could even default to
> primary and use a macrocall below
>
> Another way to handle defaults
> \define alert(alert-class.....
> <$set name=alert-class value="$alert-class$" emptyValue="alert
> alert-primary">
> ....
>
> Then use as follows
>
> <<alert "primary" "text" [width]>>
>
> []=[optional]
>
> <$macrocall $name=alert text="Text" /> uses default
> <$macrocall $name=alert alert-class="primary"
> text=<<avariableormacrooutput>> />
> <$macrocall $name=alert alert-class="secondary" text={{!!afieldname}} />
> <$macrocall $name=alert alert-class="danger" text="Text" />
>
> Good night
> See ya Tomorrow
> Tony
>
>
>
> On Tuesday, 21 August 2018 23:10:13 UTC+10, Mohammad wrote:
>>
>> I have developed several macros for creating alerts! The difference among
>> them is only the classes.
>> What is the shortest solution to implement these macros in Tiddlywiki?
>>
>>
>> I have used the below approach: A general macro and call it for specific
>> purpose from another macro!
>>
>>
>> \define __myclsl(type) alert $type$
>>
>> \define alert(text:"", type:"alert-primary", width:"100%")
>> <div class=<<__myclsl $type$>> style="width:$width$;">
>> $text$
>> </div>
>> \end
>>
>> \define alert-primary(text, width:"100%")
>> <div class="alert alert-primary" style="width:$width$;">
>> $text$
>> </div>
>> \end
>>
>> \define alert-secondary(text, width:"100%")
>> <<alert text:"$text$" type:"alert-secondary" width:"$width$">>
>> \end
>>
>> \define alert-success(text, width:"100%")
>> <<alert text:"$text$" type:"alert-success" width:"$width$">>
>> \end
>>
>> \define alert-danger(text, width:"100%")
>> <<alert text:"$text$" type:"alert-danger" width:"$width$">>
>> \end
>>
>> \define alert-warning(text, width:"100%")
>> <<alert text:"$text$" type:"alert-warning" width:"$width$">>
>> \end
>>
>>
>> *Mohammad*
>>
>>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/b27bfc6e-13c7-4a7f-9137-f3be7809b64f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.