Skip to content

Instantly share code, notes, and snippets.

@catmando
Last active December 21, 2015 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catmando/44957cae205ff7e3b062 to your computer and use it in GitHub Desktop.
Save catmando/44957cae205ff7e3b062 to your computer and use it in GitHub Desktop.
Test React.rb editable single page app file
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Inline Reactive Ruby Demo</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="inline-reactive-ruby.js" />
<STYLE type="text/css">
H1.myclass {border-width: 1; border: solid; text-align: center}
</STYLE>
<!-- scripts can be remote or inline -->
<script type="text/ruby">
class Clock < React::Component::Base
before_mount do
state.time! Time.now
every(1) { state.time! Time.now }
end
def render
"The time is #{state.time}"
end
end
</script>
<script type="text/ruby">
Element["body"].render { Clock() }
</script>
</head>
<body>
<div id="clock"></div>
<div>The time brought to you by <a href="https://github.com/reactive-ruby/inline-reactive-ruby">inline-reactive-ruby</a></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment