Last active
December 21, 2015 18:10
-
-
Save catmando/44957cae205ff7e3b062 to your computer and use it in GitHub Desktop.
Test React.rb editable single page app file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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