Skip to content

Commit b04a918

Browse files
committed
Add js example to syntax highlight preview
1 parent 3202d0f commit b04a918

File tree

2 files changed

+3
-5
lines changed
  • app
    • javascript/controllers/syntax-highlight
    • views/settings/syntax_highlights

2 files changed

+3
-5
lines changed

app/javascript/controllers/syntax-highlight/preview.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { Controller } from '@hotwired/stimulus';
2-
import debug from '../../utils/debug';
3-
4-
const console = debug('app:javascript:controllers:syntax-highlight:preview');
52

63
export default class extends Controller {
74
static values = {
8-
name: String,
5+
name: String, // The name of the syntax highlight css file to enable
96
};
107

118
connect() {
12-
console.log('connect', this.nameValue);
139
const name = this.nameValue;
1410
document
1511
.querySelectorAll('link[rel="stylesheet"][data-syntax-highlight]')

app/views/settings/syntax_highlights/form.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def each(&)
6666
CSS
6767
end
6868
end
69+
h3 { %(JavaScript) }
70+
render CodeBlock::AppFile.new("app/javascript/controllers/syntax-highlight/preview.js", language: "js")
6971
h3 { %(HTML with ERB) }
7072
render CodeBlock::AppFile.new("app/views/layouts/application.html.erb", language: "erb")
7173
end

0 commit comments

Comments
 (0)