Skip to content

Commit

Permalink
README: add html+ESM example
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Renatus <[email protected]>
  • Loading branch information
srenatus committed Nov 22, 2024
1 parent abe4873 commit f832aee
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ the Rego syntax definition file (`rego.min.js` or `rego.es.min.js`). Include it
```html
<!DOCTYPE html>
<html>
<head>
<title>Highlight.js Rego Demo</title>
<link rel="stylesheet" href="path/to/theme.css">
<script type="text/javascript" src="path/to/highlight.min.js"></script>
<script type="text/javascript" src="path/to/rego.min.js"></script>
<script type="text/javascript">hljs.highlightAll();</script>
</head>

<body>
<pre><code class="language-rego">
<head>
<title>Highlight.js Rego Demo</title>
<link rel="stylesheet" href="path/to/theme.css">
<script type="text/javascript" src="path/to/highlight.min.js"></script>
<script type="text/javascript" src="path/to/rego.min.js"></script>
<script type="text/javascript">hljs.highlightAll();</script>
</head>
<body>
<pre><code class="language-rego">
# METADATA
# description: Your Rego policy here!
package policy
Expand All @@ -33,10 +32,34 @@ default allow := false
allow if {
# ..conditions..
}
</code></pre>
</body>
</code></pre>
</body>
</html>
```

or use the ES modules from a JS CDN:

```html
<!DOCTYPE html>
<html>
<head>
<title>Highlight.js Rego Demo</title>
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/[email protected]/styles/default.min.css">
<script type="module">
import hljs from 'https://unpkg.com/@highlightjs/[email protected]/es/highlight.min.js';
import rego from 'https://unpkg.com/@styra/[email protected]/dist/rego.es.min.js';
hljs.registerLanguage('rego', rego);
hljs.highlightAll();
</script>
</head>
<body>
<pre><code class="language-rego">
package policy
default allow := false
</code></pre>
</body>
</html>

```

## How to build
Expand Down

0 comments on commit f832aee

Please sign in to comment.