How to transform tag attribute?

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

How to transform tag attribute?

Eno

I'm using a jquery plugin ( http://www.jqueryscript.net/animation/Simple-jQuery-Plugin-For-Responsive-Sliding-View-SimpleSlideView.html ) on Amber smalltalk.

there are HTML structures needed to be transformed to Amber. 

One pattern is as below:

<li><a href="#what" data-pushview>Title 1</a></li>

which I transformed to Amber as:

canvas li with: [ canvas a href: '#what' ; at: 'attr' put:  'data-pushview' ; with: 'What it does' ] .

But could not show up the expected result of scrolling and sliding..

I wondered I'm wrong at tranforming the 'data-pushview' attribute ?

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How to transform tag attribute?

Herby Vojčík


EnoX1 wrote:

>
> I'm using a jquery plugin (
> http://www.jqueryscript.net/animation/Simple-jQuery-Plugin-For-Responsive-Sliding-View-SimpleSlideView.html 
> ) on Amber smalltalk.
>
> there are HTML structures needed to be transformed to Amber.
>
> One pattern is as below:
>
> |<||li||><||a| |href||=||"#what"| |data-pushview>Title 1</||a||></||li||>|
>
> which I transformed to Amber as:
>
> canvas li with: [ canvas a href: '#what' ; at: 'attr' put:
> 'data-pushview' ; with: 'What it does' ] .

This is really strange, it should definitely be not at: 'attr'; it should be at: 'data-pushview' put: 'data-pushview', but then it will not be in the shortened form;' shortened form is not possible AFAIK (but full form should work as well).

OTOH, you can use snippets, where you define pieces of HTML in the page itself, and reuse them in code, so you can put

  <li data-snippet="myPushview"><a data-pushview data-snippet="*"></a></li>

wherever in a page, amber takes it away when sta
rted, remembers it under supplied name (myPushView) and inserting point (the one with data-snippet="*", <a> in this example), and in the code you can include the clone of it much more straightforward:

  canvas myPushview href: '#what'; with: 'Title 1'

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Eno
Reply | Threaded
Open this post in threaded view
|

Re: How to transform tag attribute?

Eno
Thanks.

Another question need help:

I'm porting zentable ( www.jqueryscript.net/demo/jQuery-Plugin-For-Manipulating-Tabulated-Data-Zentable/ )
the jquery codes:
    $("#table").zentable({
        cols: [{name:'Surname', editable:true}, {name:'Name and title', editable:true}, {name:'Room'}, {name:'Boat'}, {name:'Destination'}],
        ....

I wrote it in Amber as:
      '#table' asJQuery zentable: #{
            'cols' -> #( #{ 'name' -> 'Surname' . 'editable' -> true }  #{ 'name' -> 'Name and title' . 'editable' -> true } ...... }

but the compiler won't pass while encountering the  # for the first hashedColletion inside the literal array.

How to overcome it in Amber?

best regards.


Herby於 2013年10月1日星期二UTC+8下午9時48分32秒寫道:


EnoX1 wrote:

>
> I'm using a jquery plugin (
> http://www.jqueryscript.net/animation/Simple-jQuery-Plugin-For-Responsive-Sliding-View-SimpleSlideView.html
> ) on Amber smalltalk.
>
> there are HTML structures needed to be transformed to Amber.
>
> One pattern is as below:
>
> |<||li||><||a| |href||=||"#what"| |data-pushview>Title 1</||a||></||li||>|
>
> which I transformed to Amber as:
>
> canvas li with: [ canvas a href: '#what' ; at: 'attr' put:
> 'data-pushview' ; with: 'What it does' ] .

This is really strange, it should definitely be not at: 'attr'; it should be at: 'data-pushview' put: 'data-pushview', but then it will not be in the shortened form;' shortened form is not possible AFAIK (but full form should work as well).

OTOH, you can use snippets, where you define pieces of HTML in the page itself, and reuse them in code, so you can put

  <li data-snippet="myPushview"><a data-pushview data-snippet="*"></a></li>

wherever in a page, amber takes it away when sta
rted, remembers it under supplied name (myPushView) and inserting point (the one with data-snippet="*", <a> in this example), and in the code you can include the clone of it much more straightforward:

  canvas myPushview href: '#what'; with: 'Title 1'

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How to transform tag attribute?

Herby Vojčík


EnoX1 wrote:
> '#table' asJQuery zentable: #{
> 'cols' -> #( #{ 'name' -> 'Surname' . 'editable' -> true } #{ 'name'
> -> 'Name and title' . 'editable' -> true } ...... }
>
> but the compiler won't pass while encountering the # for the first
> hashedColletion inside the literal array.

The compiler is doing its work perfectly. You cannot want to have HashedCollection, which is not a literal, in a literal array.

> How to overcome it in Amber?

There is no way to overcome it. A literal array is an array of literals. This is the same for all Smalltalk dialects I know.

You can use dynamic array, though; in all dialects that have it (Squeak, Pharo, Amber, maybe others).

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Eno
Reply | Threaded
Open this post in threaded view
|

Re: How to transform tag attribute?

Eno
Thanks again.

I'm porting jquery plugins as some sort of exercises for training my skills on Amber smalltalk.

Sometimes, the js codes are hard or too tedious to be ported and thus needed to be inlined as a whole.

But timt to time, the js codes contained "<" or ">" or even """ double quotes, etc insides which are keywords used for Amber to call the js codes.

So, is there ways to work around the limitation to escapes these keywords?

Thanks.



Herby於 2013年10月2日星期三UTC+8下午11時00分55秒寫道:


EnoX1 wrote:
> '#table' asJQuery zentable: #{
> 'cols' -> #( #{ 'name' -> 'Surname' . 'editable' -> true } #{ 'name'
> -> 'Name and title' . 'editable' -> true } ...... }
>
> but the compiler won't pass while encountering the # for the first
> hashedColletion inside the literal array.

The compiler is doing its work perfectly. You cannot want to have HashedCollection, which is not a literal, in a literal array.

> How to overcome it in Amber?

There is no way to overcome it. A literal array is an array of literals. This is the same for all Smalltalk dialects I know.

You can use dynamic array, though; in all dialects that have it (Squeak, Pharo, Amber, maybe others).

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How to transform tag attribute?

Manfred Kröhnert
Hi,

if I remember correctly you can escape the single '<' / '>' by doubling them like '<<' / '>>'.

As for the double quotes you can just use single quotes '.
In JavaScript both ' and " can be used interchangeably so you should prefer using the single quote form with Amber.

Best,
Manfred




On Thu, Oct 3, 2013 at 5:45 PM, EnoX1 <[hidden email]> wrote:
Thanks again.

I'm porting jquery plugins as some sort of exercises for training my skills on Amber smalltalk.

Sometimes, the js codes are hard or too tedious to be ported and thus needed to be inlined as a whole.

But timt to time, the js codes contained "<" or ">" or even """ double quotes, etc insides which are keywords used for Amber to call the js codes.

So, is there ways to work around the limitation to escapes these keywords?

Thanks.



Herby於 2013年10月2日星期三UTC+8下午11時00分55秒寫道:


EnoX1 wrote:
> '#table' asJQuery zentable: #{
> 'cols' -> #( #{ 'name' -> 'Surname' . 'editable' -> true } #{ 'name'
> -> 'Name and title' . 'editable' -> true } ...... }
>
> but the compiler won't pass while encountering the # for the first
> hashedColletion inside the literal array.

The compiler is doing its work perfectly. You cannot want to have HashedCollection, which is not a literal, in a literal array.

> How to overcome it in Amber?

There is no way to overcome it. A literal array is an array of literals. This is the same for all Smalltalk dialects I know.

You can use dynamic array, though; in all dialects that have it (Squeak, Pharo, Amber, maybe others).

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.