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

11
LINES

< > BotCompany Repo | #1002214 // htag - make HTML tag. uses trailing slash (e.g. <img ... />) when contents is empty

JavaX fragment (include)

static S htag(S tag) {
  ret htag(tag, "");
}

static S mapMethodLike htag(S tag, O contents, O... params) {
  S openingTag = hopeningTag(tag, params);
  S s = str(contents);
  if (empty(s) && neqic(tag, "script"))
    ret dropLast(openingTag) + "/>";
  ret openingTag + s + "</" + tag + ">";
}

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, qsqiayxyrbia, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1002214
Snippet name: htag - make HTML tag. uses trailing slash (e.g. <img ... />) when contents is empty
Eternal ID of this version: #1002214/8
Text MD5: f2a365ed8336adcd7dd85264f8579d49
Author: stefan
Category: javax html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-09 13:19:07
Source code size: 304 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 783 / 2209
Version history: 7 change(s)
Referenced in: #1002423 - tag - make HTML tag - synonym of htag
#1002427 - Accellerating 629 (SPIKE)
#1006400 - hopeningTag - make opening HTML tag
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1007923 - containerTag - make HTML tag, avoid the short syntax (<tag/>)
#1013784 - hfulltag - make HTML tag; don't collapse if empty
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)