python:
import json
posts = [
{'author':'JL Rowling','title':'Harry Potter'},
{'author':'JRR Tolkien','title':'Lord of the Rings'},
]
encoded_posts = json.dumps(posts)
javascript:
let obj = {{ encoded_posts }};
JS ошибка в консоли:
Uncaught SyntaxError: Unexpected token ';'
Вот страница согласно КОНСОЛИ. Вроде теряет (?) {{encoded_posts}}
.
<!DOCTYPE html>
<html>
<head>
<title>Flask Blog - About</title>
</head>
<body>
<h1>About page!</h1>
<script>
let text = document.getElementsByTagName('h1')[0];
text.addEventListener('click',function(){
text.style.color = 'red';
});
let obj = ;
let jsonPosts = JSON.parse();
console.log(jsonPosts);
</script>
</body>
</html>
Что происходит?