Giter Site home page Giter Site logo

Comments (3)

tierpod avatar tierpod commented on June 19, 2024

Hello, thank you for the report.

Could you please explain this use case more detailed? IIRC, I haven't exported this variable for external template on purpose. I assume, if you use external_template (and you write this template) you can hardcode necessary assets path in this template.

from dmarc-report-converter.

moorereason avatar moorereason commented on June 19, 2024

First, I've been looking for a simple tool like dmarc-report-converter that doesn't require a bunch of resources and infrastructure (preferably written in Go). I've setup an AWS SES sub-domain to deliver reports to an S3 bucket, which I pull down before running dmarc-report-converter. It's working great so far, so thank you for all of the hard work you've put into this project before I showed up complaining about things. 😆

My use case started with wanting to hack on the default template (htmlTmpl from consts.go). I copied the contents to a separate file and ran it. Right out of the gate, I got errors and had to define my own template variable and rewrite all references of .AssetsPath to $AssetsPath. This is when I opened this issue (in haste!).

But then I quickly realized that the default contexts are completely different. The external template's default context is just the pkg/dmarc.Report struct. So, I had to rewrite all of that, too (something like s/({{\s*\.)Report./$1/g).

I find all of that an annoying learning curve and a barrier to entry for newcomers (like me). I don't see the harm in exporting AssetsPath. If the user doesn't want to use it, they don't have to. IMHO, it would be more intuitive to have the same contexts in each template so that I could use the built-in templates as a guide.

Potential Fix

A potential backward-compatible fix could be something like:

type TmplCtx struct {
	AssetsPath      string
	Report          dmarc.Report

	// Deprecate these properties
	XMLName         xml.Name
	ReportMetadata  dmarc.ReportMetadata
	PolicyPublished dmarc.PolicyPublished
	Records         []dmarc.Record
	MessagesStats   dmarc.MessagesStats
}

from dmarc-report-converter.

tierpod avatar tierpod commented on June 19, 2024

Thank you for explanation.

I understand your use case and it's completely valid. I agree that it would be better for new users to have consistent variables across all kind of templates (didn't think about it when I implemented external template).

from dmarc-report-converter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.