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

38
LINES

< > BotCompany Repo | #1026135 // HAbstractRenderable - HTML renderable base class

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

Libraryless. Click here for Pure Java version (7844L/51K).

abstract sclass HAbstractRenderable {
  S baseLink = "";
  MakeFrame makeFrame = (title, contents) -> h1_title(title) + contents;

  sinterface MakeFrame {
    S makeFrame(S title, S contents);
  }
  
  *() {}
  *(S *baseLink) {}
  
  HAbstractRenderable makeFrame(MakeFrame makeFrame) {
    this.makeFrame = makeFrame;
    this;
  }
  
  S baseLinkPlus(S uri) {
    ret nempty(uri) ? appendSlash(baseLink) + uri : baseLink;
  }
  
  // title is in HTML
  S frame(S title, S contents) {
    ret makeFrame.makeFrame(title, contents);
  }
  
  S refreshWithMsgs(S... msgs) { ret refreshWithMsgs(asList(msgs)); }
  
  S refreshWithMsgs(LS msgs, O... _) {
    optPar S anchor;
    optPar SS params;
    ret hrefresh(addAnchorToURL(appendQueryToURL(baseLink,
      mapPlus(params, msg := htmlEncode_nlToBr(lines_rtrim(msgs)))), anchor));
  }
  
  S renderMsgs(SS params) {
    ret pUnlessEmpty(params.get("msg"));
  }
}

Author comment

Began life as a copy of #1026001

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1026135
Snippet name: HAbstractRenderable - HTML renderable base class
Eternal ID of this version: #1026135/11
Text MD5: 5f2e3a34cb56fc1b5f981f6963be5dc1
Transpilation MD5: 88ec3b0e726868f4673c73bf17c2518a
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-08 16:59:12
Source code size: 953 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 298 / 694
Version history: 10 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)