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


< > 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   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, 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: 358 / 369
Version history: 2 change(s)
Referenced in: [show references]

Formerly at &