Uncaught SyntaxError: Unexpected token < in HTML - can't solve

2.9k views Asked by At

Can anyone help me find this unexpected token? I've been looking at this code for a while so maybe i need a fresh pair of eyes to solve this. see HTML code below:

<div class="list-view hide">
                    <table class="custom-reports-table">
                        <script id="custom-reports-table" type="text/javascript">
                        <tbody>
                             {{#each listItem}}
                                <tr class="row" id="{{itemId}}">
                                    <td class="select-container">
                                        <div class="select-container">
                                            <input id="{{itemId}}"type="checkbox" class="checkbox">
                                        </div>
                                    </td>
                                    <td class="preview-container"> 
                                        <i class="icon icon-pictos-115"></i>
                                        <i class="icon icon-pictos-172"></i>
                                        <i class="fa fa-asterisk report-type-icon"></i>
                                    </td>

                                    <td class="report-info">
                                        <h3 class="report-name">{{itemName}}</h3>
                                        <p class="summary">
                                            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                                            tempor incididunt.
                                        </p>
                                    </td>
                                    <td class="row-actions">
                                        <a class="tooltip tip-btn-duplicate" href="#">
                                            <span class="duplicate">Duplicate</span>
                                            <i class="fa fa-copy btn-duplicate-item"></i>
                                        </a>
                                        <a class="tooltip tip-btn-generate" href="#">
                                            <span class="generate">Generate</span>
                                            <i class="fa fa-dot-circle-o btn-generate-item"></i>
                                        </a>
                                        <a class="tooltip tip-btn-schedule" href="#">
                                            <span class="schedule">Schedule</span>
                                            <i class="fa fa-clock-o btn-schedule-item"></i>
                                        </a>
                                        <a class="tooltip tip-btn-remove btn-remove-item" href="#">
                                            <span class="remove-report">Remove</span>
                                            <i class="fa fa-times-circle-o btn-remove-item"></i>
                                        </a>
                                    </td>

                                </tr>
                             {{/each}}
                        </tbody>
                        </script>
                    </table>
                </div><!-- end of: .list-view-->

According to the console It looks like the error is somewhere related to the tbody but i can't find anything wrong. Anyone know what it might be? Thanks!

2

There are 2 answers

0
deceze On BEST ANSWER

You need to set the type of <script> correctly:

<script id="custom-reports-table" type="text/x-handlebars-template">

If you're telling the browser to evaluate HTML as Javascript, of course you'll get syntax errors from the Javascript interpreter.

3
Siguza On

I'm pretty sure that is a JavaScript error:

<script id="custom-reports-table" type="text/javascript">
    <tbody>
    // Much HTML...
    </tbody>
</script>

You try to run some HTML markup as JavaScript.
Either you missed the <script> tag there, or you don't know how JavaScript works.
In that case I'm unable to tell what your intention is with that, but that's most likely the source of your error.