Commit 6b53ababecdba0c13a79601e0876fdd51df29c25
1 parent
a34deddd
make format_attrs function for CoreAttrs assemble classes and styles into a sing…
…le attribute for each one
Showing
1 changed file
with
63 additions
and
8 deletions
Show diff stats
web/CXM_making_a_web_site.anubis
| @@ -2954,7 +2954,6 @@ public define String | @@ -2954,7 +2954,6 @@ public define String | ||
| 2954 | ( | 2954 | ( |
| 2955 | List(CoreAttrs) attributs | 2955 | List(CoreAttrs) attributs |
| 2956 | ). | 2956 | ). |
| 2957 | - | ||
| 2958 | 2957 | ||
| 2959 | public define String | 2958 | public define String |
| 2960 | format_extra_operands | 2959 | format_extra_operands |
| @@ -3238,7 +3237,7 @@ define Printable_tree | @@ -3238,7 +3237,7 @@ define Printable_tree | ||
| 3238 | . format(t)] | 3237 | . format(t)] |
| 3239 | }. | 3238 | }. |
| 3240 | 3239 | ||
| 3241 | -public define String | 3240 | + public define String |
| 3242 | format_attrs | 3241 | format_attrs |
| 3243 | ( | 3242 | ( |
| 3244 | List(CoreAttrs) attributs | 3243 | List(CoreAttrs) attributs |
| @@ -3297,15 +3296,15 @@ define String | @@ -3297,15 +3296,15 @@ define String | ||
| 3297 | if length(classes) = 0 then "" else " class=\""+join(" ",classes)+"\""+ | 3296 | if length(classes) = 0 then "" else " class=\""+join(" ",classes)+"\""+ |
| 3298 | if length(styles) = 0 then "" else " style=\""+join(";",styles)+"\"", | 3297 | if length(styles) = 0 then "" else " style=\""+join(";",styles)+"\"", |
| 3299 | [h . t] then | 3298 | [h . t] then |
| 3300 | - with current = if h is | 3299 | + with new_classes = if h is class(class_name) then [class_name. classes] else classes, |
| 3300 | + new_styles = if h is style(style_string) then [style_string . styles] else styles, | ||
| 3301 | + current = if h is | ||
| 3301 | { | 3302 | { |
| 3302 | id(id_name) then | 3303 | id(id_name) then |
| 3303 | " id=\"" + id_name + "\"", | 3304 | " id=\"" + id_name + "\"", |
| 3304 | - class(class_name) then | ||
| 3305 | - format_attrs(t, [class_name. classes], styles), | ||
| 3306 | - style(style_string) then | ||
| 3307 | - format_attrs(t, classes, [style_string . styles]), | ||
| 3308 | - title(title_string) then | 3305 | + class(class_name) then "", |
| 3306 | + style(style_string) then "", | ||
| 3307 | + title(title_string) then | ||
| 3309 | " title=\"" + title_string + "\"", | 3308 | " title=\"" + title_string + "\"", |
| 3310 | 3309 | ||
| 3311 | lang(lang) then | 3310 | lang(lang) then |
| @@ -3336,10 +3335,66 @@ define String | @@ -3336,10 +3335,66 @@ define String | ||
| 3336 | define String | 3335 | define String |
| 3337 | format_attrs | 3336 | format_attrs |
| 3338 | ( | 3337 | ( |
| 3338 | + List(CoreAttrs) attributs, | ||
| 3339 | + List(String) classes, | ||
| 3340 | + List(String) styles | ||
| 3341 | + )= | ||
| 3342 | + if attributs is | ||
| 3343 | + { | ||
| 3344 | + [] then | ||
| 3345 | + (if length(classes) = 0 then "" else " class=\""+join(" ",classes)+"\"")+ | ||
| 3346 | + if length(styles) = 0 then "" else " style=\""+join(";",styles)+"\"", | ||
| 3347 | + [h . t] then | ||
| 3348 | + with new_classes = if h is class(class_name) then [class_name. classes] else classes, | ||
| 3349 | + new_styles = if h is style(style_string) then [style_string . styles] else styles, | ||
| 3350 | + current = if h is | ||
| 3351 | + { | ||
| 3352 | + id(id_name) then | ||
| 3353 | + " id=\"" + id_name + "\"", | ||
| 3354 | + class(class_name) then "", | ||
| 3355 | + style(style_string) then "", | ||
| 3356 | + title(title_string) then | ||
| 3357 | + " title=\"" + title_string + "\"", | ||
| 3358 | + | ||
| 3359 | + lang(lang) then | ||
| 3360 | + " xml:lang=" + lang, | ||
| 3361 | + dir(reading_Way) then | ||
| 3362 | + if reading_Way is | ||
| 3363 | + { | ||
| 3364 | + ltr then " dir=ltr", | ||
| 3365 | + rtl then " dir=rtl" | ||
| 3366 | + }, | ||
| 3367 | + | ||
| 3368 | + accesskey(key) then | ||
| 3369 | + " accesskey=\"" + key + "\"", | ||
| 3370 | + tabindex(index) then | ||
| 3371 | + " tabindex=\"" + index + "\"", | ||
| 3372 | + | ||
| 3373 | + attr(name, value) then | ||
| 3374 | + " " + name + "=\"" + value + "\"", | ||
| 3375 | + | ||
| 3376 | + event(e, value) then | ||
| 3377 | + " " + event_name(e) + "=\"" + value + "\"", | ||
| 3378 | + data(name, value) then | ||
| 3379 | + " data-" + to_lower(name) + "=\"" + value + "\"", | ||
| 3380 | + }, | ||
| 3381 | + current + format_attrs(t, new_classes, new_styles) | ||
| 3382 | + }. | ||
| 3383 | + | ||
| 3384 | +define String | ||
| 3385 | + format_attrs | ||
| 3386 | + ( | ||
| 3339 | List(InputAttrs) attributs | 3387 | List(InputAttrs) attributs |
| 3340 | )= | 3388 | )= |
| 3341 | format_attrs(attributs, [], []). | 3389 | format_attrs(attributs, [], []). |
| 3342 | 3390 | ||
| 3391 | +public define String | ||
| 3392 | + format_attrs | ||
| 3393 | + ( | ||
| 3394 | + List(CoreAttrs) attributs | ||
| 3395 | + )= | ||
| 3396 | + format_attrs(attributs, [], []). | ||
| 3397 | + | ||
| 3343 | define String | 3398 | define String |
| 3344 | format_text_options | 3399 | format_text_options |
| 3345 | ( | 3400 | ( |