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

9
LINES

< > BotCompany Repo | #1008417 // hAddToHead - insert tag in <head>

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

Libraryless. Click here for Pure Java version (2583L/17K).

// if <head> block exists: put tag after <head>
// if not: add tag in front of the whole HTML
sS hAddToHead(S html, S tag) {
  L<S> tok = htmlTok(html);
  L<S> head = first(findContainerTag(tok, "head"));
  if (head == null) ret tag + html;
  head.set(2, addLineBreak(tag) + head.get(2));
  ret join(tok);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1008417
Snippet name: hAddToHead - insert tag in <head>
Eternal ID of this version: #1008417/3
Text MD5: 9ab12cbbaf4704035b1793b5db38e695
Transpilation MD5: 234e5dbb9e4f028a8c4e675c8204b46a
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-05 16:33:03
Source code size: 315 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 534 / 582
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1024237 - hAddToHead_fast - insert tag in <head>, faster version that should also be correct
#1028276 - hAddToBody - insert content in <body> tag (at end)
#1028277 - hAddToHeadAndBody - insert stuff in <head> and <body>