Skip to content

Latest commit

 

History

History
116 lines (88 loc) · 4.82 KB

readme.md

File metadata and controls

116 lines (88 loc) · 4.82 KB

dogetest

Dogetest is a descent into the madness of dogescript.

As I attempted to get a page to run dogescript "natively", and by natively I mean just either:

  • a script tag with dogescript ran through dogescript.parse and then through eval
  • a script tag with src pointing to dogescript
  • or loading a .djs file and running that

I ended up descending into the crazyness that is webpack,browserify and all that jazz.

However, the index.html page that you see in this repo is the finished playground of getting something to run.

instructions

  1. Get NPM if you don't have it, you can find that guy here since most of the things you'll need get installed with node.
  2. Get dogescript which you will install with npm (globally using the -g flag) npm install -g dogescript
  3. Get browserify as all the samples use require and then bundle everything with browserify into a bundle.js file npm install browserify

Each additional sample will add some more instructions on how to get that particular piece working

samples

The following folders contain enough javascript/html to just load the sample in a page and nothing fancy.

The console will log the converted dogescript with a "Compiled Dogescript:" message.

Every sample will include this snippet in the index.js:

// define a global function that can run text dogescript
dogerunner = function(ds)
{
  eval(dogescript(ds));
}

So you can have fun also calling dogescript from the chrome console. Caveat, I've only tried this out in chrome.

Run string based dogescript

basedogescript:

  • index.js: contains a require('dogescript') call and uses eval and dogescript to display an alert
dogescript = require('dogescript');
eval(dogescript("plz alert with 'have dogescript'"));
  • index.html: a blank page to load the bundle.js file
  • bundle.js: a generated bundle.js file with browserify: browserify index.js > bunde.js

Required npm installs:

  • dogescript
  • browserify

Run dogescript from a file

filedogescript:

  • index.js: contains a require('dogescript') call, a require('fs') and uses brfs to load a file with dogescript in it and then eval it.
  • colorp.djs: dogescript file that changes div#diverino .p to font-color red
  • index.html: page that loads bundle.js file and has the div and paragraph to colorize
  • bundle.js: a generated bundle.js file with browserify browserify -t brfs index.js > bundle.js

Required npm installs:

  • dogescript
  • browserify
  • brfs (for embedding the files as part of the browserify building)

Run dogescript in script tag

tagdogescript:

  • index.js: ** contains the required imports: require('dogescript') and require('xhr') when attempting to load tags with a src attribute. This probably won't work locally, but it might when pushed on git. ** also, it will contain modified code to attempt to eval and dogescript dogescript text embedded in script tags, this chunk can be found here and was supposed to end up being released in 2.4.0, but 2.4.0 never happened. ** a slight modification has been made, to refer to parse as dogescript based on the aliasing of dogescript=require('dogescript')
  • index.html: page to load the bundle file, as well as code in embedded script tags. One of them will change the paragraph text and the other (the src based one) will append a new element to the div
<div id="diverino">
<p>Some paragraph text</p>
</div>

<script src="bundle.js"></script>

<script type="text/dogescript">
very divy is document dose getElementById with 'diverino'
very pary is divy.children[0]
pary.textContent is 'changed with doge'
</script>

<script src="dogeappend.djs" type="text/dogescript"></script>
  • dogeappend.djs: a file that will append a second paragraph to diverino with content "i am appended"
* `bundle.js`: everything bundled up (with the index.js modifications)
`browserify index.js > bunde.js`

Required npm installs:
- dogescript
- browserify
- xhr (for loading files)

### Run your own dogescript
`rundogescript`:
* `index.js`: contains `require('dogescript')`, and the bits from "run dogescript in script tag", as well as an exposed function `dogerunner` which will be available globally
* `index.html`: a modified version of the dogescript [example](https://github.com/dogescript/dogescript/tree/master/example/WOWserify) with a panel for writing dogescript, a panel for showing the resulting javascript, and a button for modifying stuff. As well as our friendly `diverino` div for playing with
* `bundle.js`: everything packed up and ready to go
`browserify index.js > bunde.js`

Required npm installs:
- dogescript
- browserify
- xhr (for loading files)