Richard Eng wrote: > Another question I have is: Since Silk is a way to *not* rely on JQuery, > how would you collect the values in the form without using JQuery? IOW, > I can't use... > > (('#myForm1 *'asJQuery)filter:':input') AFAIK ':input', ':checked', ':visible' and others are jQuery-specific and are not actually part of CSS machinery. In Silk, you can only do what classical DOM-built CSS allows you to do, so: '#myForm' asJQuery allAt: 'input,select,option' will get you the array of Silk-wrapped <input>s, <select>s and <option>s that reside under #myForm. There is also at: to only get first such element; and you can send at: and allAt: directly to Silk to search the whole document. BTW, '#myForm *' asJQuery filter: ':input' scares me. Why not '#myForm' asJQuery children: ':input' or '#myForm' asJQuery find: ':input'? > On Wednesday, 24 June 2015 19:09:34 UTC-4, Richard Eng wrote: > > I think I like this style best: > > '#client-main' asSilk > FORM > TABLE in: [ :table | > table TR in: [ :row | > row TD: 'Username:'. > row TD INPUT: 'name'->'name' ]. > table TR in: [ :row | > row TD: 'Password:'. > row TD INPUT: {'name'->'password'. 'type'->'password'} ]. > table TR TD INPUT: {'type'->'submit'. 'value'->'Okay'} ] > > But I'm puzzled by 'FORM' and 'TABLE'. You don't actually say what > these are shortcuts for, and I can't figure out how to add an > attribute, eg, 'id'->'myForm1'. I've tried various things to no avail. > > > On Wednesday, 24 June 2015 16:00:24 UTC-4, Herby wrote: > > > > Richard Eng wrote: > > You're right. The last example did not break. > > Released 0.1.4 with `Silk TAG:` working. > > > On Wednesday, 24 June 2015 15:25:42 UTC-4, Herby wrote: > > > > > > > > Richard Eng wrote: > > > I notice that the class-side #doesNotUnderstand: is slightly > > different > > > from the instance-side #doesNotUnderstand:, which is why your > > examples > > > break. You're right, when I do 'Silk new TAG:', it works. > > > > I told `Silk newStream TAG:`, `Silk new TAG:` does something > slightly > > different (of course, '#client-div' asSilk is also an > instance, that's > > why there the TAG: form works as well; also the last example > uses > > instances, so AfAICT, it is not breaking (you wrote all of them > > break)). > > > > > On Wednesday, 24 June 2015 14:44:46 UTC-4, Herby wrote: > > > > > > > > > > > > Herby Vojčík wrote: > > > > > > > > > > > > Richard Eng wrote: > > > >> Here's what I've concluded... > > > >> > > > >> With the exception of #FORM:, *none* of the other TAG:'s > work. I > > > have to > > > >> use '<<' with 'Silk TAG'. That's why all of your example > break. > > > > > > I looked at sources; you are mixing "Silk TAG:" with > "aSilkInstance > > > TAG:". It is indeed true that "Silk TAG:" does not work > (from the > > > examples it is clear, though, that it is useful), and on > the other > > > hand, > > > all "aSilkInstance TAG:" work (not just FORM:). > > > > > > Nevertheless, it should be easy to use "Silk newStream TAG:" > > instead of > > > "Silk TAG:" and it should just work. > > > > > > I will probably add direct "Silk TAG:". > > > > > > > I just don't believe that, #FORM: has no specialty at all > and > > > Silk has > > > > unit tests which test lots of scenarios, including making > some > > table > > > > using TAG and TAG: messages. > > > > > > > >> On Wednesday, 24 June 2015 12:29:27 UTC-4, Richard Eng > wrote: > > > >> > > > >> Where you use 'Silk open', I also get: > > > >> > > > >> Silk does not understand #open > > > > > > > > #open must just work, it's normally implemented (in > DOMite, from > > > which > > > > Silk inherits). > > > > > > > > You must have something wrong in your setup. > > > > > > > >> On Wednesday, 24 June 2015 12:22:40 UTC-4, Richard Eng > wrote: > > > >> > > > >> In all of your code examples where you use #TD:, I get: > > > >> > > > >> Silk does not understand #TD: > > > >> * > > > >> * > > > >> (I'm just cut-and-pasting into my application.) > > > >> > > > >> Am I doing something wrong, or is your article incorrect? > > > >> > > > >> > > > >> On Wednesday, 24 June 2015 04:48:54 UTC-4, Herby wrote: > > > >> > > > >> > > > >> > > > >> Richard Eng wrote: > > > >> > Hmmm, something's wrong. Even with 'Silk TD LABEL:', the > > > >> cells in the > > > >> > table are not aligning correctly. This was never a > > > >> problem with the Web > > > >> > package. > > > >> > > > > >> > > > > >> > On Tuesday, 23 June 2015 20:53:23 UTC-4, Richard Eng > wrote: > > > >> > > > > >> > Oh, so simple: > > > >> > > > > >> > Silk TD LABEL: 'Username:' > > > >> > > > > >> > > > > >> > On Tuesday, 23 June 2015 20:51:04 UTC-4, Richard Eng > wrote: > > > >> > > > > >> > Hmmm... > > > >> > > > > >> > Silk does not understand #TD: > > > >> > > > > >> > What's the correct way to add a label? > > > >> > > > > >> > > > > >> > On Thursday, 11 June 2015 11:07:05 UTC-4, Herby wrote: > > > >> > > > > >> > > > > >> > > > > >> > Richard Eng wrote: > > > >> > > I don't disagree with you, but as Martin pointed > out, in > > > >> > a typical web > > > >> > > application project, you are *given* HTML; you are not > > > >> > asked to > > > >> > > write/generate HTML. > > > >> > > > > > >> > > Nevertheless, in the next installment of the Amber > > > >> > tutorial, I *will* be > > > >> > > examining Silk. > > > >> > > > > > >> > > > > > >> > > On Thursday, 11 June 2015 10:50:36 UTC-4, Herby wrote: > > > >> > > > > > >> > > > > > >> > > > > > >> > > Richard Eng wrote: > > > >> > > > It's very easy to insert raw HTML instead of using > > > >> > HTMLCanvas. > > > >> > > For example, > > > >> > > > > > > >> > > > || > > > >> > > > '#client-main'asJQuery append: > > > >> > > > '<form> > > > >> > > > <table> > > > >> > > > <tr><td>Username:</td><td><input > name="name"></td></tr> > > > >> > > > <tr><td>Password:</td><td><input name="password" > > > >> > > type="password"></td></tr> > > > >> > > > <tr><td><input type="submit" value="Okay"></td></tr> > > > >> > > > </table> > > > >> > > > </form>' > > > >> > > > > >> > Just in case, above thing could probably written this > way in > > > >> > Silk: > > > >> > > > > >> > '#client-main' asSilk > > > >> > FORM > > > >> > TABLE > > > >> > TR: { > > > >> > Silk TD: 'Username:'. > > > >> > Silk TD INPUT: 'name'->'name' }; > > > >> > TR: { > > > >> > Silk TD: 'Password'. > > > >> > Silk TD INPUT: { 'name'->'password'. > 'type'->'password' }}; > > > >> > TR: { > > > >> > Silk TD INPUT: { 'type'->'submit'. 'value'->'Okay' } > > > >> > > > >> This is not correct code. See the medium article for > correct > > > >> pieces. > > > >> > > > >> > > > > >> > Of course, it could be written other ways, too, as it is > > > >> > pretty flexible > > > >> > in ways how to insert content into an element. This piece > > > >> > uses `TAG: > > > >> > content` convenient method heavily. > > > >> > > > > >> > (uppercase needed, as DNU is used to generate tags > from any > > > >> > uppercase > > > >> > message, so you can insert you custom tags as well) > > > >> > > > > >> > > > > > > >> > > > I just thought it'd be nice to use Smalltalk to > > > >> > programmatically > > > >> > > create > > > >> > > > the HTML. I used Seaside many years ago, so it's what > > > >> I'm > > > >> > > familiar with; > > > >> > > > in Seaside, there was no other way to use HTML > (most web > > > >> > > frameworks use > > > >> > > > HTML templates). > > > >> > > > > > > >> > > > In fact, for all future work, I'm inclined to inject > > > >> > raw HTML. > > > >> > > It's much > > > >> > > > > > >> > > IMNSHO, this is unhappy inclination. I very hope if not > > > >> > Web then at > > > >> > > least Silk allows you to use objects, not strings > > > >> > regularly. It has > > > >> > > different approach, maybe having simple methods > returning > > > >> > array of > > > >> > > elements / a wrapped DocumentFragment could be seen as > > > >> > flexible enough > > > >> > > (while retaining objects all the way). > > > >> > > > > > >> > > > more flexible than the programmatic approach and is > > > >> > much more > > > >> > > natural > > > >> > > > for Amber (than it is for Pharo). However, I still > need > > > >> > to solve the > > > >> > > > issue of > > > >> > > > > > > >> > > > (('#myForm1 *'asJQuery)filter:':input') > > > >> > > > > > > >> > > > crapping out on me when a false value causes a break > > > >> > from the loop. > > > >> > > > > > > >> > > > > > > >> > > > On Thursday, 11 June 2015 01:24:27 UTC-4, Martin Bähr > > > >> > wrote: > > > >> > > > > > > >> > > > Excerpts from Richard Eng's message of 2015-06-11 > > > >> > 05:40:09 +0200: > > > >> > > > > Thanks to Herby's (very extensive) proofreading and > > > >> > vetting, I've > > > >> > > > made many > > > >> > > > > substantial changes to the article, esp. the coding > > > >> > examples. > > > >> > > > It's now > > > >> > > > > ready for publishing and I've posted it at Reddit: > > > >> > > > > > > > >> > > > > > > > >> > > > > > > >> > > > > > >> > > > > >> > > > > > > http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>> > > > > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>>> > > > > > > > > > >> > > > >> > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>> > > > > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>>>> > > > > > > > > > >> > > > >> > > > >> > > > > >> > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>> > > > > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>>> > > > > > > > > > >> > > > >> > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>> > > > > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>>>>> > > > > > > > > > >> > > > >> > > > >> > > > > >> > > > > > >> > > > > >> > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>> > > > > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>>> > > > > > > > > > >> > > > >> > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>> > > > > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>>>> > > > > > > > > > >> > > > >> > > > >> > > > > >> > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>> > > > > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/>>> > > > > > > > > > >> > > > >> > > > > > > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/ > <http://www.reddit.com/r/programming/comments/39e5cq/a_gentle_introduction_to_amber/> > > > < > > ... > > -- > 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] > <mailto:[hidden email]>. > For more options, visit https://groups.google.com/d/optout. -- 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/d/optout. |
In reply to this post by horrido
Richard Eng wrote: > I think I like this style best: > > '#client-main' asSilk > FORM > TABLE in: [ :table | > table TR in: [ :row | > row TD: 'Username:'. > row TD INPUT: 'name'->'name' ]. > table TR in: [ :row | > row TD: 'Password:'. > row TD INPUT: {'name'->'password'. 'type'->'password'} ]. > table TR TD INPUT: {'type'->'submit'. 'value'->'Okay'} ] I sort-of understand, it is the shortest of all the examples, and resembling Seaside the most. OTOH, this is the most un-Silk one, as Silk has the philosophy of "putting bunch of things on to a stream", so in case you extracted parts of your structure to another method, the method should return directly the thing to put on the stream (array of elements or Silk newStream holding those elements), so it looks something like: '#client-main' asSilk FORM TABLE TR: self usernameRowContent; TR: self passwordRowContent; TR: self submitRowContent or, returning with enclosing <tr>, '#client-main' asSilk FORM TABLE: { self usernameRow. self passwordRow. self submitRow } not as it is done with Web (and would be needed with this block-based philosphy): table := '#client-main' asSilk FORM TABLE. self renderUsernameRowOn: table. self renderPasswordRowOn: table. self renderSubmitRowOn: table eventually table := '#client-main' asSilk FORM TABLE. self renderUsernameRowContentsOn: table TR. self renderPasswordRowContentsOn: table TR. self renderSubmitRowContentOn: table TR IOW, I tried to make Silk less imperative and more descriptive; especially in that notion that extraction should not be done with renderXxxOn: methods but with xxx / xxxContent methods. But, of course, you are the one writing the article. -- 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/d/optout. |
In reply to this post by Herby Vojčík
Maybe I'm just too dense, but I don't understand the mechanism behind 'FORM TABLE'. FORM returns a form element to which you send the TABLE message? That doesn't make sense to me. FORM and TABLE are both DOM elements. On Thursday, 25 June 2015 06:39:15 UTC-4, Herby wrote:
|