In case you were wondering if this is possible, it is. And it’s pretty simple, as well.

The first thing to do is modify your theme’s header.php file to include enyo.js.  For example, I am using the PageLines theme and here is how I modified my header.php:


...
  <script src="/enyo/enyo.js"></script>
  <link href="/enyo/enyo.css" rel="stylesheet"></link>
</head>
...

Make sure you are using a local copy of enyo.js and any other libraries you need.

Now you can write <script> tags in your pages and posts to include Enyo components, like this:


<script>
  enyo.depends("$lib/onyx", "$lib/layout");
</script>

If you want to use the package system (to include layout or onyx as I did), then you need to run the enyo.depends() method in its own <script> tag before your main logic.


<script>
  enyo.kind({
    name: "Example",
    kind: "enyo.FittableColumns",
    classes: "enyo-center",
    components: [
      {kind: "onyx.Button", content: "Tap Me!", ontap: "alertMe"}
    ],
    alertMe: function() {
      this.log("TAPPED");
      alert("TAPPED");
    }
  });
  new Example().write();
</script>

 

One Response to Kindly Add to WordPress Pages and Posts

  1. […] been experimenting with various integration scenarios for Enyo.  Sticking with what I have worked on so far, I decided to try my hand at writing a WordPress widget that displays an Enyo application.  You […]

Leave a Reply

Your email address will not be published. Required fields are marked *