UserContentComponent.vala 1.0 KB

1234567891011121314151617181920
  1. // This file demonstrates the spry-mkconst workflow:
  2. // 1. The HTML template (UserContentComponent.vala.html) is converted to a const using spry-mkconst
  3. // 2. The generated const (USER_CONTENT_COMPONENT_VALA_HTML) is referenced in the markup property
  4. // 3. This allows the Vala language server to still recognize this file as valid Vala code
  5. class UserContentComponent : Component {
  6. public override string markup { get { return USER_CONTENT_COMPONENT_VALA_HTML; } }
  7. private HttpContext http_context = inject<HttpContext>();
  8. public async override void handle_action(string action) throws Error {
  9. this["message"].text_content = http_context.request.query_params.get_any_or_default("message") ?? "No message provided!";
  10. this["action"].text_content = action;
  11. }
  12. }
  13. // Generated by spry-mkconst (would be in a separate file or included via build system):
  14. // const string USER_CONTENT_COMPONENT_VALA_HTML = """
  15. // <p>You said: <strong sid="message"></strong> <em>(via <span sid="action"></span>)</em></p>
  16. // """;