github.com/servernoj/jade@v0.0.0-20231225191405-efec98d19db1/testdata/v2/attributes.jade (about)

     1  
     2  a(href=`google.com`+`google.com`) Google
     3  |
     4  |
     5  a(class='button' href='google.com') Google
     6  |
     7  |
     8  a(class='button', href='google.com') Google
     9  
    10  
    11  - var authenticated = true
    12  body(class=authenticated ? "authed" : "anon")
    13  
    14  
    15  input(
    16    type='checkbox'
    17    name='agreement'
    18    checked
    19  )
    20  
    21  
    22  input(data-json=`
    23    {
    24      "very-long": "piece of ",
    25      "data": true
    26    }
    27  `)
    28  
    29  
    30  //- In this case, `(click)` is treated as a
    31  //- function call instead of a attribute name,
    32  //- resulting in the unusual error.
    33  // pug error
    34  div(class='div-class' (click)='play()')
    35  
    36  
    37  div(class='div-class', (click)='play()')
    38  div(class='div-class' '(click)'='play()')
    39  
    40  
    41  a(href="/#{url}") Link
    42  
    43     
    44     - var url = "pug-test.html"
    45     a(href="/" + url) Link
    46     |
    47     |
    48     - url = "https://example.com/"
    49     a(href=url) Another link
    50     
    51     
    52     - var btnType = "info"
    53     - var btnSize = "lg"
    54     button(type='button' class="btn btn-" + btnType + " btn-" + btnSize)
    55     |
    56     |
    57     button(type='button' class=`btn btn-${btnType} btn-${btnSize}`)
    58     
    59  
    60  div(escaped="<code>")
    61  div(unescaped!="<code>")
    62  
    63  
    64  input(type='checkbox', checked)
    65  |
    66  |
    67  input(type='checkbox' checked=true)
    68  |
    69  |
    70  input(type='checkbox' checked=false)
    71  |
    72  |
    73  input(type='checkbox' checked="true")
    74  
    75  
    76  doctype html
    77  |
    78  |
    79  input(type='checkbox', checked)
    80  |
    81  |
    82  input(type='checkbox' checked=true)
    83  |
    84  |
    85  input(type='checkbox' checked=false)
    86  |
    87  |
    88  input(type='checkbox' checked=true && "checked" == "checked")
    89  
    90  
    91  a(style=map[string]string{"color": "red", "background": "green"})
    92  
    93  
    94  - var classes = []string{"foo", "bar", "baz"}
    95  a(class=classes)
    96  |
    97  |
    98  //- the class attribute may also be repeated to merge arrays
    99  a.bang(class="classes" class="['bing']")
   100  
   101  
   102  - var currentUrl = "/about"
   103  a(class= currentUrl == "/" ? "active" : "" href='/') Home
   104  |
   105  |
   106  a(class= currentUrl == "/about" ? "active" : "" href='/about') About
   107  
   108  
   109  a.button
   110  
   111  
   112  .content
   113  
   114  
   115  a#main-link
   116  
   117  
   118  #content
   119  
   120  
   121  div#foo(data-bar="foo")&attributes({'data-foo': 'bar'})
   122  
   123  //-
   124  - var attributes = struct{class string}{};
   125  - attributes.class = "baz";
   126  div#foo(data-bar="foo")&attributes(attributes)
   127  
   128  zxc.asd(num=1 class="qwe").zxc
   129  zxc(num=1.1)