Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: add html+ESM example #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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