Pfff...

The creator of web2py says he wishes he could do web3py some other way, but 
can't...

Am I the only one that finds that funny? :)

web3py will end up however you wish it to end up as...

You can do whatever you want with it, as it's already inherently backwards 
incompatible (python 3.x), and is not even fully planned yet...

If anyone at any time could change things, it would be you guys and at this 
time...

How about putting auxiliary attributes "front and center"?
Data-* attributes are already a part of the standard of HTML5 and 
most-if-not-all browsers support them.

Single-Page apps are also not even considered a novelty anymore, and we're 
in a Renaissance of data-binding frameworks...

I mean, I guess I could do this:

def DATA(name, value):
    return {('_data-' + name):str(value)}
    

Then:

DIV( "{{MyVar}}", **DATA( "ng-controller", "MyController" ) )
=>
DIV( "{{MyVar}}", **{ "_data-ng-controller": "MyController" } )
=>
<div data-ng-controller="MyController">{{MyVar}}</div>

and:

DIV( "{{MyVar}}", **DATA( "bind", "text: MyVar" ) )
=>
DIV( "{{MyVar}}", **{ "_data-bind": "text: MyVar" } )
=>
<div data-bind="text: MyVar">{{MyVar}}</div>


But hell, you can make the TAG classes able to receive DATA 
class-instances, that other people can sub-class/modify to implenet the 
interface for different frameworks.

A generic DATA class may look something like this:

class DATA:

    namespace = ""
    
    aggregate = False
    seperator = ": "
    delimiter = ", "

    def __init__(self, **attrs):
        self.attrs = dict(**attrs)
        ...

    def parse( self ):
        parsed = ""
        
        if aggregatre:
            parsed += 'data-' + ns + '="'
            for k, v in items(self.attrs):
                parsed += k + seperator + v + delimiter
            parsed = parsed[:-len(delimiter)] + '"'            
        else:
            ns  = namespace + '-' if namespace else ''
            for k, v in items(self.attrs):
                parsed += 'data-' + ns + k + '="' + v + '"'
        
        return parsed  


And have your TAG classes do something like:

class <TAG>:
    def __init__(self, content, *vars, **args):
        ...
        parsed = [ var.parsed() for var in *vars if isinstanceof(var, DATA) 
]
        ...
        <use parsed somehow>
        ...


Angular guys may then do something like this:

DATA.namespace = "ng"
BUTTON( "Delete", DATA( click="destroy()", show="project._id".) )
=>
<button data-ng-click="destroy()" data-ng-show="project._id">Delete</button>

or:

class ngDATA( DATA ):
    namespace = "ng"

+ <use ngDATA instead of DATA in the html helpers>


Knockout guys could do this:

DATA.namespace = "bind"
DATA.aggregate = True
SELECT( "", DATA( options = "$root.availableMeals",
                                   value = "meal".
                                   optionsText = "'mealName'" ) )
=>
<select data-bind="options: $root.availableMeals, value: meal, optionsText: 
'mealName'"></select>

or:

class koDATA( DATA ):
    namespace = "bind"
    aggregated = False

+ <use koDATA instead of DATA in the html helpers>


What say you?

On Thursday, December 20, 2012 7:17:48 AM UTC-8, Massimo Di Pierro wrote:
>
> Oops. right. I wish there was a simple syntax but I cannot think about 
> one. 
>
> On Thursday, 20 December 2012 09:07:21 UTC-6, Niphlod wrote:
>>
>> correction, the _ in front is needed as always .... 
>> DIV('content',**{'_data-something':'something value'})
>>
>> Il giorno giovedì 20 dicembre 2012 15:58:25 UTC+1, Massimo Di Pierro ha 
>> scritto:
>>>
>>> They always did although the syntax is cumbersone
>>>
>>> DIV('content',**{'data-something':'something value'})
>>>
>>> On Thursday, 20 December 2012 04:16:54 UTC-6, Arnon Marcus wrote:
>>>>
>>>> Cool (!)
>>>>
>>>> Do the HTML helpers support HTML5's " data-* " attributes?
>>>> Can that be used for javascriupt frameworks like Knockout.js or 
>>>> Angular.js ?
>>>>
>>>

-- 



Reply via email to