(t *testing.T)
| 270 | } |
| 271 | |
| 272 | func TestEvalBlockYieldIncludeNode(t *testing.T) { |
| 273 | var data = make(VarMap) |
| 274 | |
| 275 | data.Set("user", &User{ |
| 276 | "José Santos", "email@example.com", |
| 277 | }) |
| 278 | |
| 279 | RunJetTest(t, data, nil, "Block_simple", `{{block hello() "Buddy" }}Hello {{ . }}{{end}},{{yield hello() user.Name}}`, `Hello Buddy,Hello José Santos`) |
| 280 | RunJetTest(t, data, nil, "Block_Extends", `{{extends "Block_simple"}}{{block hello() "Buddy" }}Hey {{ . }}{{end}}`, `Hey Buddy,Hey José Santos`) |
| 281 | RunJetTest(t, data, nil, "Block_Import", `{{import "Block_simple"}}{{yield hello() "Buddy"}}`, `Hello Buddy`) |
| 282 | RunJetTest(t, data, nil, "Block_Import", `{{import "Block_simple"}}{{yield hello() "Buddy"}}`, `Hello Buddy`) |
| 283 | |
| 284 | JetTestingLoader.Set("Block_ImportInclude1", `{{yield hello() "Buddy"}}`) |
| 285 | RunJetTest(t, data, nil, "Block_ImportInclude", `{{ import "Block_simple"}}{{include "Block_ImportInclude1"}}`, `Hello Buddy`) |
| 286 | RunJetTest(t, data, nil, |
| 287 | "Block_Content", |
| 288 | "{{ block col(md=12,offset=0) }}\n<div class=\"col-md-{{md}} col-md-offset-{{offset}}\">{{ yield content }}</div>\n\t\t{{ end }}\n\t\t{{ block row(md=12) }}\n<div class=\"row {{md}}\">{{ yield content }}</div>\n\t\t{{ content }}\n<div class=\"col-md-1\"></div>\n<div class=\"col-md-1\"></div>\n<div class=\"col-md-1\"></div>\n\t\t{{ end }}\n\t\t{{ block header() }}\n<div class=\"header\">\n\t{{ yield row() content}}\n\t\t{{ yield col(md=6) content }}\n{{ yield content }}\n\t\t{{end}}\n\t{{end}}\n</div>\n\t\t{{content}}\n<h1>Hey</h1>\n\t\t{{ end }}", |
| 289 | "\n<div class=\"col-md-12 col-md-offset-0\"></div>\n\t\t\n\t\t\n<div class=\"row 12\">\n<div class=\"col-md-1\"></div>\n<div class=\"col-md-1\"></div>\n<div class=\"col-md-1\"></div>\n\t\t</div>\n\t\t\n\t\t\n<div class=\"header\">\n\t\n<div class=\"row 12\">\n\t\t\n<div class=\"col-md-6 col-md-offset-0\">\n\n<h1>Hey</h1>\n\t\t\n\t\t</div>\n\t\t\n\t</div>\n\t\t\n</div>\n\t\t", |
| 290 | ) |
| 291 | |
| 292 | JetTestingLoader.Set("BlockContentLib", "{{block col(columns)}}\n <div class=\"col {{columns}}\">{{yield content}}</div>\n{{end}}\n{{block row(cols=\"\")}}\n <div class=\"row\">\n {{if len(cols) > 0}}\n {{yield col(columns=cols) content}}{{yield content}}{{end}}\n {{else}}\n {{yield content}}\n {{end}}\n </div>\n{{end}}") |
| 293 | RunJetTest(t, nil, nil, "BlockContentParam", |
| 294 | `{{import "BlockContentLib"}}{{yield row(cols="12") content}}{{cols}}{{end}}`, |
| 295 | "\n <div class=\"row\">\n \n \n <div class=\"col 12\">12</div>\n\n \n </div>\n") |
| 296 | |
| 297 | JetTestingLoader.Set("BlockContentLib2", ` |
| 298 | {{block col( |
| 299 | columns, |
| 300 | )}} |
| 301 | <div class="col {{columns}}">{{yield content}}</div> |
| 302 | {{end}} |
| 303 | {{block row( |
| 304 | cols="", |
| 305 | rowClass="", |
| 306 | )}} |
| 307 | <div class="row {{ rowClass }}"> |
| 308 | {{if len(cols) > 0}} |
| 309 | {{yield col(columns=cols) content}} |
| 310 | {{yield content}} |
| 311 | {{end}} |
| 312 | {{else}} |
| 313 | {{yield content}} |
| 314 | {{end}} |
| 315 | </div> |
| 316 | {{end}} |
| 317 | `) |
| 318 | RunJetTest(t, nil, nil, "BlockContentParam2", |
| 319 | `{{import "BlockContentLib2"}} |
| 320 | {{yield row( |
| 321 | cols="12", |
| 322 | rowClass="highlight-row", |
| 323 | ) content}} |
| 324 | {{cols}} |
| 325 | {{end}}`, |
| 326 | "\n\t\t\t<div class=\"row highlight-row\">\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t<div class=\"col 12\">\n\t\t\t\t\t\t\n\t\t\t12\n\t\t\n\t\t\t\t\t</div>\n\t\t\n\t\t\t\t\n\t\t\t</div>\n\t\t", |
| 327 | ) |
| 328 | } |
| 329 |
nothing calls this directly
no test coverage detected
searching dependent graphs…