GithubHelp home page GithubHelp logo

esxml's Introduction

Read Me

This library was created to fascilitate quickly building web pages, though it also includes tools for working with parsed xml

Code Generation with esxml.el

This library provides to formats for xml code generation. The primary form is esxml. esxml is the form that is returned by such functions as libxml-parse-xml-region and is used internally by emacs in many xml related libraries.

A brief example

The following is a very simple esxml document, paths are handled directly, via a case statement. While this is not good practice, this is meant to be a very simple example.

sxml example

(let ((count 0))
  (defun sxml-demo (httpcon)
    (incf count)
    (case (intern (elnode-http-pathinfo httpcon))
      (/messages (with-current-buffer "*Messages*"
                   (sxml-to-xml `(html (body (pre ,(buffer-string)))))))

      (t (sxml-to-xml
          `(html
            (body
             (h1 "Hello from Emacs!") (br)
             "Trying to visit " ,(format "%s" (elnode-http-pathinfo httpcon)) (br)
             "Visit " (a (@ (href "/messages")) "messages") " to see the *Messages* buffer." (br)
             "Have been visited " ,(format "%s" count) " times since last started.")))))))

This outputs the following HTML:

<html >
  <body >
    <h1 >Hello from Emacs!</h1><br />
    Trying to visit /anywhere<br />
    Visit <a href="/messages">messages</a> to see the *Messages* buffer.<br />
    Have been visited 1 times since last started.
  </body>
</html>

esxml example

(let ((count 0))
  (defun esxml-demo (httpcon)
    (incf count)
    (case (intern (elnode-http-pathinfo httpcon))
      (/messages (with-current-buffer "*Messages*"
                   (esxml-to-xml `(html () (body () (pre () ,(buffer-string)))))))
      
      (t (esxml-to-xml
          `(html ()
                 (body ()
                       (h1 () "Hello from Emacs!")
                       (br) "Trying to visit " ,(format "%s" (elnode-http-pathinfo httpcon))
                       (br)  "Visit " (a ((href . "/messages")) "messages")  " to see the *Messages* buffer."
                       (br) "Have been visited " ,(format "%s" count) " times since last started.")))))))

Advanced examples

A standard page generator

Extracting Data from XML

TODO

esxml's People

Contributors

nicferrier avatar tali713 avatar wasamasa avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.