File: lasso

package info (click to toggle)
ruby-rouge 4.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,836 kB
  • sloc: ruby: 38,168; sed: 2,071; perl: 152; makefile: 8
file content (48 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?LassoScript
/* Lasso 8 */
  local('query' = 'SELECT * FROM `'+var:'table'+'` WHERE `id` > 10
    ORDER BY `Name` LIMIT 30');
  Inline: -Username=$DBuser, -Password=$DBpass, -Database=$DBname, -sql=#query;
    var("class1.name" = (found_count != 0 ? "subtotal" | "nonefound"),
        "total_amount" = found_count || "No results");
    records;
      output: "<tr>"loop_count"</tr>";
    /records;
  /Inline;
?><div class="[$class1.name]">[$total_amount]</div>
<?lasso
/* Lasso 9 */ ?>
[noprocess] causes [delimiters] to be <?=skipped?> until the next [/noprocess]
[
  define strings.combine(value::string, ...other)::string => {
    local(result = #value->append(#other->asString&trim))
    return set(#result, not #other, \givenBlock)
  }
  /**! descriptive text */
  define person => type {
    parent entity
    data name::string, protected nickname, birthdate :: date
    data private ssn = null
    private showAge() => frozen { return ..age }
    protected fullName() => `"` + .nickname + `"` + .'name'
    public ssnListed::boolean => .ssn() ? true | false
  }
  define person->name=(value) => {
    .'name' = #value
    return self->'name'
  }
  define bytes->+(rhs::bytes) => bytes(self)->append(#rhs)&
] <!-- an HTML comment <?=disables delimiters?> as well -->
[no_square_brackets] disables [square brackets] for the rest of the file
<?=
  // query expression
  with n in array((:-12, 0xABCD, 3.14159e14), (:NaN, -infinity, .57721))
  let swapped = pair(#n->\second, #n->first)
  group #swapped by #n->first into t
  let key = #t->key
  order by #key
  select pair(#key, #1)
  do {^
    #n->upperCase
  ^}
?>