3

Simple problem here but unfortunately can't solve. As mentioned in the title, I can't get Riot to show the contents of its custom tag.

<!DOCTYPE html>
<html>
<head></head>
<body>
    <hello></hello>
    <script type="text/javascript" src="node_modules/riot/riot.min.js"></script>
    <script type="text/javascript"> riot.mount('*'); </script>

    <script type="text/javascript" src="bower_components/lodash/lodash.min.js"></script>
    <script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="bower_components/toastr/toastr.min.js"></script>
    <script type="text/javascript" src="js/init.js"></script>
    <script type="text/javascript" src="js/config.js"></script>
    <script type="text/javascript" src="js/util.js"></script>
    <script type="text/javascript" src="js/hello.js"></script>
</body>

The hello.js is the generated js, here is its code:

riot.tag('hello', '<div> asdasd </div>', function(opts) {
});

And here is its HTML:

<hello>
    <div>
        asdasd
    </div>
    <script>
    </script>
</hello>
edi9999
  • 19,701
  • 13
  • 88
  • 127
rnldpbln
  • 654
  • 3
  • 11
  • 22

2 Answers2

5

You can't mount your tag before declaring it.

You need to do in this order:

Include riot:

<script type="text/javascript" src="node_modules/riot/riot.min.js"></script>

Declare your tags:

<script type="text/javascript" src="js/init.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/hello.js"></script>

Mount your declared tags:

<script type="text/javascript"> riot.mount('*'); </script>
edi9999
  • 19,701
  • 13
  • 88
  • 127
0

Woops. Scrap that. Moved the hello.js just below the riot.min.js and it worked. Apparently placing that there and above the mount is critical.

rnldpbln
  • 654
  • 3
  • 11
  • 22