Skip to content
/ cfw Public

Go ports of a few selected CFWheels helpers.

License

Notifications You must be signed in to change notification settings

bengarrett/cfw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cfw

PkgGoDev Go Report Card GitHub release (latest SemVer) GitHub

Package cfw contains ports of a few selected CFWheels v1 helpers that are used for string manipulation and have no Go equivalent.

CFWheels is an open-source CFML (ColdFusion Markup Language) framework inspired by Ruby on Rails that provides fast application development, a great organization system for your code, and is just plain fun to use.

I created this package as I had been migrating CFWheels web applications over to Go. They had a few dependencies that need recreation to ensure a smooth transition.

If you find cfw useful, consider buying me a coffee?

Documentation

https://pkg.go.dev/github.com/bengarrett/cfw

Usage

package main

import (
	"fmt"
	"time"

	"github.com/bengarrett/cfw"
)

func main() {
	// Obfuscate / DeObfuscate
	fmt.Println(cfw.Obfuscate("1234"))
	fmt.Println(cfw.DeObfuscate("a4363c"))

	// Excerpt
	fmt.Println(cfw.Excerpt(
		"CFWheels: testing the excerpt view helper to see if it works or not.",
		"[more]", "excerpt view helper", 10))

	// Humanize
	fmt.Println(cfw.Humanize("wheelsIsAFramework", ""))

	// Hyphenize
	fmt.Println(cfw.Hyphenize("wheelsIsAFramework"))

	// StripLinks
	fmt.Println(cfw.StripLinks(
		`Go to the <strong><a href="https://github.com/bengarrett/cfw">GitHub</a></strong> repo!`))

	// StripTags
	fmt.Println(cfw.StripTags(
		`Go to the <strong><a href="https://github.com/bengarrett/cfw">GitHub</a></strong> repo!`))

	// TimeDistance
	add7Seconds := time.Now().Add(time.Second * time.Duration(7))
	fmt.Println(cfw.TimeDistance(time.Now(), add7Seconds, true))

	// Truncate
	fmt.Println(cfw.Truncate(
		"CFW contains Go ports of a few selected CFWheels helpers.", "", 15))

	// WordTruncate
	fmt.Println(cfw.WordTruncate(
		"CFW contains Go ports of a few selected CFWheels helpers.", "", 4))
	fmt.Println(cfw.WordTruncate(
		"CFW contains Go ports of a few selected CFWheels helpers.", " 🥰", 3))
}
$ go run . example/main.go

a4363c
1234
[more]sting the excerpt view helper to see if[more]
Wheels Is A Framework
wheels-is-a-framework
Go to the <strong>GitHub</strong> repo!
Go to the GitHub repo!
less than 10 seconds
CFW contains...
CFW contains Go ports...
CFW contains Go 🥰

Copyright © 2021 Ben Garrett - MIT License