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.

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

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: 115 / 186
Version history: 2 change(s)
Referenced in: [show references]