Giter Club home page Giter Club logo

pagesnippets's Introduction

pageSnippets

pageSnippets is a JavaScript tool for dynamically and easily creating complex HTML or XML. Outsource parts of your big and confusing HTML and generate them on demand. No more need for messy nested document.createElement(), just code your HTML and produce() the snippets.

ECMAScript6
Standalone
License

Example

This short example to gives you a glimpse how easy it is to use pageSnippets.

  1. Compose your snippets as an XML file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<ps:pagesnippets xmlns:ps="https://github.com/suppenhuhn79/pagesnippets">
  <ps:snippet name="hello">
    <h1>Hello world!</h1>
  </ps:snippet>
</ps:pagesnippets>
  1. Include pageSnippets2.js in your HTML file. (Note that the previous version 'pageSnippets.js' is deprecated and will be discontinued.)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>pageSnippets Demo</title>
		<meta charset="utf-8" />
		<script src="https://suppenhuhn79.github.io/pagesnippets/pagesnippets2.js"></script>
	</head>
</html>
  1. Have a short script that imports the snippet file. Produce the snippet and place it in the document.
  <body>
    <script>
      pageSnippets.import("snippet.xml").then(() => document.body.appendChild(pageSnippets.produce("hello")));
    </script>
  </body>
</html>

You're done.

Of course there's more! Unleash its full power with placeholders, conditions, lists and much more. Find a full reference in the wiki.

Licence

pageSnippets is licensed under the Apache License, Version 2.0.

pagesnippets's People

Contributors

suppenhuhn79 avatar

Watchers

 avatar

pagesnippets's Issues

<ps:for-empty> does not work when array not exists

A <ps:for-empty> does not work, if the array is not provided in the data. It throws an error "<member>" is not defined. If the array is not given, <ps:for-empty> should act as if the array was empty.

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.