WATagBrush>>class:if: with boolean and additional blocks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

WATagBrush>>class:if: with boolean and additional blocks

Torsten Bergmann
WATagBrush>>class:if: is implemented like this:


    class: aString if: aBoolean
        "Adds the class aString to the receiving element if aBoolean is true.
       
        Example:
       
        html div
                class: 'error' if: self hasError;
                with: self errorMessage"

        aBoolean
                ifTrue: [ self class: aString ]


What about changing it to:

    class: aString if: aBooleanOrBlock
        ...

        aBooleanOrBlock value
                ifTrue: [ self class: aString ]


This way one could use a boolean as before but also a conditional block coming from
elsewhere. This change would also be backward compatible and not break existing code.

What do you think?

Thx
T.
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: WATagBrush>>class:if: with boolean and additional blocks

Johan Brichau-2
I’m very much in favour of that.

Similarly, we added a method #scriptBlock:if: to prevent generation of a script instead of only preventing its attachment.
I don’t like the name we chose, but the concept is something I would like to push to Seaside too.

On 30 Dec 2013, at 12:31, Torsten Bergmann <[hidden email]> wrote:

> WATagBrush>>class:if: is implemented like this:
>
>
>    class: aString if: aBoolean
> "Adds the class aString to the receiving element if aBoolean is true.
>
> Example:
>
> html div
> class: 'error' if: self hasError;
> with: self errorMessage"
>
> aBoolean
> ifTrue: [ self class: aString ]
>
>
> What about changing it to:
>
>    class: aString if: aBooleanOrBlock
> ...
>
> aBooleanOrBlock value
> ifTrue: [ self class: aString ]
>
>
> This way one could use a boolean as before but also a conditional block coming from
> elsewhere. This change would also be backward compatible and not break existing code.
>
> What do you think?
>
> Thx
> T.
> _______________________________________________
> seaside-dev mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev

_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: WATagBrush>>class:if: with boolean and additional blocks

Philippe Marschall
In reply to this post by Torsten Bergmann
On Mon, Dec 30, 2013 at 12:31 PM, Torsten Bergmann <[hidden email]> wrote:

> WATagBrush>>class:if: is implemented like this:
>
>
>     class: aString if: aBoolean
>         "Adds the class aString to the receiving element if aBoolean is true.
>
>         Example:
>
>         html div
>                 class: 'error' if: self hasError;
>                 with: self errorMessage"
>
>         aBoolean
>                 ifTrue: [ self class: aString ]


What's the use case for this?

Instead of

html tag
  class: 'class-name'
  if: (receiver selector)

you can now have:

html tag
  class: 'class-name'
  if: [ receiver selector ]

What am I missing?

> What about changing it to:
>
>     class: aString if: aBooleanOrBlock
>         ...
>
>         aBooleanOrBlock value
>                 ifTrue: [ self class: aString ]
>
>
> This way one could use a boolean as before but also a conditional block coming from
> elsewhere. This change would also be backward compatible and not break existing code.
>
> What do you think?

Ce n'est pas si facile [1]:
 * Do not assume #value is part of the Object protocol

 [1] http://code.google.com/p/seaside/wiki/CodingConventions

Cheers
Philippe
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev