Skip to content

Simple variable substitution (with example) in meta tag throwing NullPointerException #137

@JMacLulich

Description

@JMacLulich

Hi,

I'm loving enlive, however I have a weird problem with finding and replacing variables inside meta tags.

This is my html.

<meta property="og:title" content="${event-title}" />

When I apply this transformation:

(at (html-resource "templates/page-meta.html") [:meta] (replace-vars {:event-title "hello"}))

assuming the HTML content is in the file templates/page-meta.html I get this problem:

1. Unhandled java.lang.NullPointerException
   (No message)

                  Matcher.java:  701  java.util.regex.Matcher/quoteReplacement
                    string.clj:   67  clojure.string/replace-by
                    string.clj:  106  clojure.string/replace
               enlive_html.clj:  677  net.cgrand.enlive-html/replace-vars/substitute-vars
               enlive_html.clj:  683  net.cgrand.enlive-html/replace-vars/fn/iter/fn
                  LazySeq.java:   40  clojure.lang.LazySeq/sval
                  LazySeq.java:   49  clojure.lang.LazySeq/seq

Without going through the enlive sources, which I don't really have time for, I'm at a loss to explain this problem?

Any ideas?

Cheers, Jason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions