B4J Library [B4X][Web] MiniHtml

EnriqueGonzalez

Expert
Licensed User
Longtime User
i once made something very similar but it was easier as you didn't have to think in the end tags.
 

aeric

Expert
Licensed User
Longtime User
I wish I didn't need to reinvent the wheel.
Thanks for sharing.
Maybe I can borrow part of your "wheel".
 

aeric

Expert
Licensed User
Longtime User
I uploaded an example.

 

aeric

Expert
Licensed User
Longtime User
Version: 0.06

What's New:
  1. Added more code modules
  2. Fix i variable in For loop to support I code module
  3. Add Build2
  4. Add attr (pass attributes as Map)
  5. Add attribute3 (attribute without value e.g required)
  6. Add addStyle
  7. Add removeStyle
  8. Add updateClassAttribute (private)
  9. Add updateStyleAttribute (private)
  10. Add setParent and getParent for Parent property
  11. Add addId
  12. Add addName
  13. Add LinkCss
  14. Add required (attribute without value for text input)
  15. Update Build replaces Build(-1)
  16. Update add, add2, addTo, addTo2, up, up2, down, down2 by setting Parent
  17. Update ClassesAsString
  18. Update StylesAsString
  19. Update removeClass
  20. Update Raw
  21. Update Comment
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Version: 0.07

What's New:
  1. Added JSON library as dependency
  2. Renamed code modules to avoid conflicts
  3. Added new code modules
  4. Added AddId for DIV
  5. Added cdnScript and cdnScript2
  6. Added cdnStyle and cdnStyle2
  7. Added some Htmx attributes
  8. Update addStyle
  9. Update linkCss
  10. Renamed code modules with 3 characters or less changed to uppercase
  11. Some code simplified
  12. Error handling for addClass and addStyle
 

aeric

Expert
Licensed User
Longtime User
Hi, which sub do I use to inject an existing html block?
You mean raw HTML?
Previously I have Raw and Raw2 subs but renamed in latest version.
I think in most cases, just use Text sub.

B4X:
Dim block As String = "<p>This is a <b>raw</b> HTML</p>"
div1.add(Html.create("").Text(block)) ' add a block to parent div1
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Great, I hope you can afford a shortcut like addHTML that will just received the string add. Thanks..
 

aeric

Expert
Licensed User
Longtime User
Great, I hope you can afford a shortcut like addHTML that will just received the string add. Thanks..
I will think for a good way.

Actually the point of using this MiniHTML is to avoid writing raw HTML.

There is another reason why I say so.
I am trying to integrate this into my Simple HTML Editor as I mentioned here.

I want to make sure the attributes (especially style and class) added into Maps and List correctly.

Any item can be easily added or removed from the "tree" when needed.
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
Actually the point of using this MiniHTML is to avoid writing raw HTML.
well yes, but raw html is also important, for sure there will be some scenarios that you wont be able to forsee or if you do, you will find the code move convoluted

look how BSS implements it:
 

aeric

Expert
Licensed User
Longtime User
It is easy to add the raw or plain html.
I already done it.
But I want to proceed to parse the html as a child into inner tags.
I am now trying with Erel's MiniHtmlParser but getting an error.

B4X:
B4J line: 290
If Input.Contains(\
shell\src\b4j\example\minihtmlparser_subs_0.java:1095: error: incompatible types: input cannot be converted to RemoteObject
if (true) return minihtmlparser._input;};
                               ^
1 error

Edit: I think there is a conflict with my "Input" module.
 

Attachments

  • MiniHtml.zip
    21.5 KB · Views: 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…