From 3174f75e214c285efcaf26b785bc804bb7126193 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Wed, 12 Feb 2025 23:05:59 +0100 Subject: [PATCH] added HtmlElement class --- samples/HelloElement/README.md | 5 +++++ samples/HelloElement/main.cpp | 8 ++++++++ samples/HelloElement/project.json | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 samples/HelloElement/README.md create mode 100644 samples/HelloElement/main.cpp create mode 100644 samples/HelloElement/project.json diff --git a/samples/HelloElement/README.md b/samples/HelloElement/README.md new file mode 100644 index 0000000..66f7395 --- /dev/null +++ b/samples/HelloElement/README.md @@ -0,0 +1,5 @@ +![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true) + +This sample demonstrates the use of the ``HtmlElement`` class. + +Run ``crafter-webbuild serve -c debug`` and go to ``localhost:8080`` to view it. \ No newline at end of file diff --git a/samples/HelloElement/main.cpp b/samples/HelloElement/main.cpp new file mode 100644 index 0000000..f806cbf --- /dev/null +++ b/samples/HelloElement/main.cpp @@ -0,0 +1,8 @@ +import Crafter.CppDOM; +using namespace Crafter::CppDOM; + +int main(){ + HtmlElement body("body"); + body.SetInnerHTML("Hello World!"); + //No need to call FreeJs, this is done in the destructor of HtmlElement. +} \ No newline at end of file diff --git a/samples/HelloElement/project.json b/samples/HelloElement/project.json new file mode 100644 index 0000000..34fe905 --- /dev/null +++ b/samples/HelloElement/project.json @@ -0,0 +1,23 @@ +{ + "name": "hello-element", + "configurations": [ + { + "name": "debug", + "standard": "c++26", + "source_files": ["main"], + "module_files": [], + "additional_files": [], + "build_dir": "./build", + "output_dir": "./bin", + "optimization_level": "0", + "target": "wasm32-unknown-wasi", + "type": "executable", + "dependencies": [ + { + "path":"../../project.json", + "configuration":"debug" + } + ] + } + ] +}