Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1028276 // hAddToBody - insert content in <body> tag (at end)

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (2666L) is out of date.

1  
// if <body> block exists: put tag before </body>
2  
// if not: append to whole HTML
3  
// TODO: use something better than findContainerTag
4  
sS hAddToBody(S html, S contents) {
5  
  if (emptyAfterTrim(contents)) ret html;
6  
  L<S> tok = htmlTok(html);
7  
  LS body = first(findContainerTag(tok, "body"));
8  
  if (body == null) ret joinWithEmptyLines(html, contents);
9  
  int i = l(body)-3;
10  
  body.set(i, joinWithEmptyLines(body.get(i), contents));
11  
  ret join(tok);
12  
}

Author comment

Began life as a copy of #1008417

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028276
Snippet name: hAddToBody - insert content in <body> tag (at end)
Eternal ID of this version: #1028276/3
Text MD5: 7cfac9b7d9711b4bc8747beffbfd0470
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-27 18:56:49
Source code size: 458 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 199 / 286
Version history: 2 change(s)
Referenced in: [show references]